From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796289180; b=RFozU1v27pVn/4yeUnKx75Ls2Ee5EZAXzK8J9vaHIdLf4qSno9fT3eGS3uOvkvjvWD7O r1bzFeiFsVapLAIZ31CSU7ijzK8qr4zPpMY/jbTw6Gwbg27O4suLEHfWOtgCE2D14MKle zi2BBR5NPRu4uBBomhE7zifbw9kkXQP5yS25q8i0BJyvIL8HLpSaMlYjOCGffsZP9WAYz H/SeqtRV4L6mAYHaLoKyeuTxBqG0KPT8LST3PGBTv/LprOZMxD4h2RlTcMjAo+zvy9Skw pug+zazC788bc/A3yIkK/oB+Ms6orRJH9l2z4cZo8Kk1QBpTqEs3hUjVIzJdrODOqFw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796289180; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=IApBu6i4mFbrYrmzEDKVVONATvroTmc8ulvb6Mpi7mY=; b=NUuBqTI1ppQEuMzWw0LOCgd3N4eo0kM9qnRuij+vxsov/CSPK9gJDifWhTYe2ALP2U3Q NUbJVjGRLDxq52JqLVMuFz4YfyT+B5ES1Biovhw90jBGQghziSkCF39AJ2AURxRVobqPH rQGg/bp3Pu69FLSh5g94M5gygZJznaOtlv6B3100vy13eOA2RgftC3auhQuy7dI+D0cVq LAEeAXu/eahXA+lIlK4g6s/tHgY7qDFJqawezJ0kVH6cplk0p8gnJbroZQjrT9sS3RuV5 7zp7iwvR7+EmJgeQsjh8+1xzRM47t+YiqiMgOHFbxmaDKAYEazbN0via1zO0XgrUPmw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass header.d=baylibre.com header.i=@baylibre.com header.a=rsa-sha256 header.s=google header.b=CL4YD+IE; arc=none smtp.remote-ip=209.85.128.52 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70A2D606A322 for ; Thu, 3 Dec 2026 09:12:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 70A2D606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.a=rsa-sha256 header.s=google header.b=CL4YD+IE Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4a5177d78c7so145803805e9.2 for ; Thu, 03 Dec 2026 01:12:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1796289177; x=1796893977; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=IApBu6i4mFbrYrmzEDKVVONATvroTmc8ulvb6Mpi7mY=; b=CL4YD+IEa0qn8Ae7l3GLWaGmGMDj83i/blahR99Qg9KwNy9Rh1u+KmGso+MmnsJe9n Nq85/aQpfL/R4dJXsJLd9Ii4bXldMnbMbyMtbUOHLHvpRXfKYzF/r3V6ItepkEMAnAo+ 4ne1T8N6KmQzbnnkev8aYfik6cTJbCfN06T9qsI+5/eNCCs0ZUzkYqcBazmTHpKu5vAX F0CCNxc18Lmqt0C6O7wPKXMkttEwDaswRh7WRnm1nzkzP9Am3zZPP4NYvEBLNvas6V94 oBOmTVLdSNwV4MSZ0aldRp22x0jZvlkvjhnMGhwH/xWEdWGthD672Dsn5B/tTaQDgKKB 7GnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796289177; x=1796893977; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=IApBu6i4mFbrYrmzEDKVVONATvroTmc8ulvb6Mpi7mY=; b=xEJI3fuLhK/Lj8s1jmlEiUPAiySOsnW5z9u1QO3iU02uR5E2R37j636qPULx1er3a2 Uc3UGAa4zhIblex+bRwj+7R2c+RmdCfwolMYuz02ieo5WPniCeaKu33W4dU3XoRIzVel MNdMgI7bSkJgfUrZsOCSJJvVf7LyRw7caP5P757L5QyMmZrmktZ3NyKtymKmlggwxPlv 1Jj5kDv5G9GWmAHLI6SmL460HEz4DCz4QZ3D/MkMkYTeecWy0E9X1OMw315dUAcWFaeJ HgpgqtWXwa3y27GlqlvR8yysgaga/brLr0UkLDZMvEm1dxzg91oZhavBjwptz3mWiMGZ 2QwQ== X-Forwarded-Encrypted: i=1; AL+hErHXLbpLsSTblatYsj0MfauOZjp/pyrrygAeV8glZuGmNGxBFnHue/6lX6Zq4rhUp5Qe4MRa19EB/jki@vger.kernel.org X-Gm-Message-State: APuU4Z9nXGkZypgae8KVB9+G1r9buJLpDqUwLF4byVEPD6t/yzGV2fux Cj5LUiqokZWf26yrA5jGkv+SzsAKtPxTyVWdx4ok1o4LntMpmQZjSE1h+aMj9Mmb5W8= X-Gm-Gg: AZFdTZcHZwWq6nvVLPP+nwxa9zFKzP9ZTosWZOqiRfHbsRGLaL9C8FRNasUO1pOIOSZ 5wVisplND+8mSFz5f1GyEiqdlPu5UbGRvQZh57j72TAbjATMugxq29lp6ZlHUf/qFr0vG4gWkxp KXyq3BNLcapdqi5VblaphefcSyfL1I30dAchy0wW7aAvxTQINCiaJGaOPG6otYUNFvDpDB2R4No Z5vackGEBSywRac1LpuQTZCYGqRSca1cAKA+jariByNWuoTSD2n/Y7IVJf1eVg1fWytUIcKNv4Z fJQozipuViFlIideuXRuditzqHv9vRJmUekrPn0WK9zVYub15JLMIxLrGgE+VEUJ5oe4dtFmGbQ HnX48sB0/HegJGs4UdPLh89fgBXkzxQtMlHJ9dW+8YXrFm+74j2mCH4fkYEf/fTLT7d1V98fecE 67+8XvGyF0Mz0P4MVz7Zp7TmONbkeTOQXPj64iH6YGRHkyBxXyXSx7xfD0c1esKvU6dnv8kOKJY y54mCHXe6W1L84rpjMDFIMRLoeerQRKc80Qn2mhxibMX1uj/AxMSrHxF6Hghga6AP0MP5H3KZho M6MYETiR43hzT653TnQsgLMV1/qSaH/uj3PORlxeU6YBJ/P0edp0eCkhY86oePezakFgjira3fS mZodeCfnRNOxUyCjB7/48oTRU04v+gQ8oGQs= X-Received: by 2002:a05:600c:310f:b0:4b5:d95c:2378 with SMTP id 5b1f17b1804b1-4bb8881f9b7mr886508525e9.34.1796289176034; Thu, 03 Dec 2026 01:12:56 -0800 (PST) Received: from localhost (p200300f65f125a0827810b02e4c0a7c9.dip0.t-ipconnect.de. [2003:f6:5f12:5a08:2781:b02:e4c0:a7c9]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4bbe005fa80sm55009195e9.8.2026.12.03.01.12.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 01:12:55 -0800 (PST) Date: Thu, 3 Dec 2026 10:12:54 +0100 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Ramesh Ramalingam Cc: johannes@sipsolutions.net, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-wireless@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 09/17] wifi: cc33xx: Add main.c Message-ID: References: <20261203070906.1294171-1-r-ramalingam@ti.com> <20261203070906.1294171-10-r-ramalingam@ti.com> X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="fctgpn7wf5qhqrvl" Content-Disposition: inline In-Reply-To: <20261203070906.1294171-10-r-ramalingam@ti.com> --fctgpn7wf5qhqrvl Content-Type: text/plain; protected-headers=v1; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH v6 09/17] wifi: cc33xx: Add main.c MIME-Version: 1.0 On Thu, Dec 03, 2026 at 12:38:58PM +0530, Ramesh Ramalingam wrote: > From: Michael Nemanov >=20 > General code and structures. > Notably: >=20 > cc33xx_irq - Handles IRQs received from the device. >=20 > process_core_status - Core status is a new concept in CC33xx. > it's a structure that is appended to each transfer from the device and > contains its most up-to-date status report (IRQs, buffers, etc.). > See struct core_status for details. >=20 > process_event_and_cmd_result - Responses to driver commands and > FW events both arrive asynchronously. Therefore, driver cannot know what > he read from HW until inspecting the payload. This code reads and > dispatches the data accordingly. >=20 > cc33xx_recovery_work - Driver supports basic recovery on FW crash and > other illegal conditions. This implements the recovery flow > (Remove all vifs, turn device off and on, download FW, > let ieee80211_restart_hw do the rest). >=20 > irq_deferred_work - Does irq-related work. This is mostly in response > to HW's Tx/Rx IRQs. >=20 > cc33xx_nvs_cb - Callback for the NVS FW request API. Similar to wlcore, > this is where the init of the HW is performed. >=20 > cc33xx_load_ini_bin_file - Loads a configuration file from user-space > via the request FW API. The structure is described in a separate patch. >=20 > cc33xx_op_X - MAC80211 operation handlers. >=20 > Signed-off-by: Michael Nemanov > Signed-off-by: Ramesh Ramalingam > --- > drivers/net/wireless/ti/cc33xx/main.c | 4820 +++++++++++++++++++++++++ > 1 file changed, 4820 insertions(+) > create mode 100644 drivers/net/wireless/ti/cc33xx/main.c >=20 > diff --git a/drivers/net/wireless/ti/cc33xx/main.c b/drivers/net/wireless= /ti/cc33xx/main.c > new file mode 100644 > index 000000000000..b34bed565a46 > --- /dev/null > +++ b/drivers/net/wireless/ti/cc33xx/main.c > @@ -0,0 +1,4820 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (C) 2022-2026 Texas Instruments Incorporated - https://www.= ti.com/ > + */ > + > +#include > +#include already provides platform_device_id without introducing the amount of unneeded build dependencies that does. So please drop the latter. > +#include > +#include > +#include > [...] > +static const struct ieee80211_iface_combination > +cc33xx_iface_combinations[] =3D { > + { > + .max_interfaces =3D 3, > + .limits =3D cc33xx_iface_limits, > + .n_limits =3D ARRAY_SIZE(cc33xx_iface_limits), > + .num_different_channels =3D 2, > + } Trailing , please. > +}; > + > +static const u8 cc33xx_rate_to_idx_2ghz[] =3D { > + [0] =3D CONF_HW_RXTX_RATE_UNSUPPORTED, > + [CONF_HW_RATE_INDEX_1MBPS] =3D 0, /* RATE_INDEX_1MBPS */ > + [CONF_HW_RATE_INDEX_2MBPS] =3D 1, /* RATE_INDEX_2MBPS */ > + [CONF_HW_RATE_INDEX_5_5MBPS] =3D 2, /* RATE_INDEX_5_5MBPS */ > + [CONF_HW_RATE_INDEX_11MBPS] =3D 3, /* RATE_INDEX_11MBPS */ > + [CONF_HW_RATE_INDEX_6MBPS] =3D 4, /* RATE_INDEX_6MBPS */ > + [CONF_HW_RATE_INDEX_9MBPS] =3D 5, /* RATE_INDEX_9MBPS */ > + [CONF_HW_RATE_INDEX_12MBPS] =3D 6, /* RATE_INDEX_12MBPS */ > + [CONF_HW_RATE_INDEX_18MBPS] =3D 7, /* RATE_INDEX_18MBPS */ > + [CONF_HW_RATE_INDEX_24MBPS] =3D 8, /* RATE_INDEX_24MBPS */ > + [CONF_HW_RATE_INDEX_36MBPS] =3D 9, /* RATE_INDEX_36MBPS */ > + [CONF_HW_RATE_INDEX_48MBPS] =3D 10, /* RATE_INDEX_48MBPS */ > + [CONF_HW_RATE_INDEX_54MBPS] =3D 11, /* RATE_INDEX_54MBPS */ > + [CONF_HW_RATE_INDEX_MCS0] =3D 0, /* RATE_INDEX_MCS0 */ > + [CONF_HW_RATE_INDEX_MCS1] =3D 1, /* RATE_INDEX_MCS1 */ > + [CONF_HW_RATE_INDEX_MCS2] =3D 2, /* RATE_INDEX_MCS2 */ > + [CONF_HW_RATE_INDEX_MCS3] =3D 3, /* RATE_INDEX_MCS3 */ > + [CONF_HW_RATE_INDEX_MCS4] =3D 4, /* RATE_INDEX_MCS4 */ > + [CONF_HW_RATE_INDEX_MCS5] =3D 5, /* RATE_INDEX_MCS5 */ > + [CONF_HW_RATE_INDEX_MCS6] =3D 6, /* RATE_INDEX_MCS6 */ > + [CONF_HW_RATE_INDEX_MCS7] =3D 7 /* RATE_INDEX_MCS7 */ Trailing , please > +}; > + > +static const u8 cc33xx_rate_to_idx_5ghz[] =3D { > + [0] =3D CONF_HW_RXTX_RATE_UNSUPPORTED, > + [CONF_HW_RATE_INDEX_1MBPS] =3D CONF_HW_RXTX_RATE_UNSUPPORTED, /* RATE_I= NDEX_1MBPS */ > + [CONF_HW_RATE_INDEX_2MBPS] =3D CONF_HW_RXTX_RATE_UNSUPPORTED, /* RATE_I= NDEX_2MBPS */ > + [CONF_HW_RATE_INDEX_5_5MBPS] =3D CONF_HW_RXTX_RATE_UNSUPPORTED, /* RATE= _INDEX_5_5MBPS */ > + [CONF_HW_RATE_INDEX_11MBPS] =3D CONF_HW_RXTX_RATE_UNSUPPORTED, /* RATE_= INDEX_11MBPS */ > + [CONF_HW_RATE_INDEX_6MBPS] =3D 0, /* RATE_INDEX_6MBPS */ > + [CONF_HW_RATE_INDEX_9MBPS] =3D 1, /* RATE_INDEX_9MBPS */ > + [CONF_HW_RATE_INDEX_12MBPS] =3D 2, /* RATE_INDEX_12MBPS */ > + [CONF_HW_RATE_INDEX_18MBPS] =3D 3, /* RATE_INDEX_18MBPS */ > + [CONF_HW_RATE_INDEX_24MBPS] =3D 4, /* RATE_INDEX_24MBPS */ > + [CONF_HW_RATE_INDEX_36MBPS] =3D 5, /* RATE_INDEX_36MBPS */ > + [CONF_HW_RATE_INDEX_48MBPS] =3D 6, /* RATE_INDEX_48MBPS */ > + [CONF_HW_RATE_INDEX_54MBPS] =3D 7, /* RATE_INDEX_54MBPS */ > + [CONF_HW_RATE_INDEX_MCS0] =3D 0, /* RATE_INDEX_MCS0 */ > + [CONF_HW_RATE_INDEX_MCS1] =3D 1, /* RATE_INDEX_MCS1 */ > + [CONF_HW_RATE_INDEX_MCS2] =3D 2, /* RATE_INDEX_MCS2 */ > + [CONF_HW_RATE_INDEX_MCS3] =3D 3, /* RATE_INDEX_MCS3 */ > + [CONF_HW_RATE_INDEX_MCS4] =3D 4, /* RATE_INDEX_MCS4 */ > + [CONF_HW_RATE_INDEX_MCS5] =3D 5, /* RATE_INDEX_MCS5 */ > + [CONF_HW_RATE_INDEX_MCS6] =3D 6, /* RATE_INDEX_MCS6 */ > + [CONF_HW_RATE_INDEX_MCS7] =3D 7 /* RATE_INDEX_MCS7 */ ditto > +}; > + > +static const u8 *cc33xx_band_rate_to_idx[] =3D { > + [NL80211_BAND_2GHZ] =3D cc33xx_rate_to_idx_2ghz, > + [NL80211_BAND_5GHZ] =3D cc33xx_rate_to_idx_5ghz ditto > +}; > + > +/* can't be const, cfg80211 writes to this */ > +static struct ieee80211_rate cc33xx_rates[] =3D { > + { .bitrate =3D 10, > + .hw_value =3D CONF_HW_BIT_RATE_1MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_1MBPS, }, No trailing , if the closing } is on the same line. My preference here would be: static struct ieee80211_rate cc33xx_rates[] =3D { { .bitrate =3D 10, .hw_value =3D CONF_HW_BIT_RATE_1MBPS, .hw_value_short =3D CONF_HW_BIT_RATE_1MBPS, }, { .... > + { .bitrate =3D 20, > + .hw_value =3D CONF_HW_BIT_RATE_2MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_2MBPS, > + .flags =3D IEEE80211_RATE_SHORT_PREAMBLE }, > + { .bitrate =3D 55, > + .hw_value =3D CONF_HW_BIT_RATE_5_5MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_5_5MBPS, > + .flags =3D IEEE80211_RATE_SHORT_PREAMBLE }, > + { .bitrate =3D 110, > + .hw_value =3D CONF_HW_BIT_RATE_11MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_11MBPS, > + .flags =3D IEEE80211_RATE_SHORT_PREAMBLE }, > + { .bitrate =3D 60, > + .hw_value =3D CONF_HW_BIT_RATE_6MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_6MBPS, }, > + { .bitrate =3D 90, > + .hw_value =3D CONF_HW_BIT_RATE_9MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_9MBPS, }, > + { .bitrate =3D 120, > + .hw_value =3D CONF_HW_BIT_RATE_12MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_12MBPS, }, > + { .bitrate =3D 180, > + .hw_value =3D CONF_HW_BIT_RATE_18MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_18MBPS, }, > + { .bitrate =3D 240, > + .hw_value =3D CONF_HW_BIT_RATE_24MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_24MBPS, }, > + { .bitrate =3D 360, > + .hw_value =3D CONF_HW_BIT_RATE_36MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_36MBPS, }, > + { .bitrate =3D 480, > + .hw_value =3D CONF_HW_BIT_RATE_48MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_48MBPS, }, > + { .bitrate =3D 540, > + .hw_value =3D CONF_HW_BIT_RATE_54MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_54MBPS, }, > +}; > + > +/* can't be const, cfg80211 writes to this */ > +static struct ieee80211_channel cc33xx_channels[] =3D { > + { .hw_value =3D 1, .center_freq =3D 2412, .max_power =3D CC33XX_MAX_TXP= WR }, > + { .hw_value =3D 2, .center_freq =3D 2417, .max_power =3D CC33XX_MAX_TXP= WR }, > + { .hw_value =3D 3, .center_freq =3D 2422, .max_power =3D CC33XX_MAX_TXP= WR }, > + { .hw_value =3D 4, .center_freq =3D 2427, .max_power =3D CC33XX_MAX_TXP= WR }, > + { .hw_value =3D 5, .center_freq =3D 2432, .max_power =3D CC33XX_MAX_TXP= WR }, > + { .hw_value =3D 6, .center_freq =3D 2437, .max_power =3D CC33XX_MAX_TXP= WR }, > + { .hw_value =3D 7, .center_freq =3D 2442, .max_power =3D CC33XX_MAX_TXP= WR }, > + { .hw_value =3D 8, .center_freq =3D 2447, .max_power =3D CC33XX_MAX_TXP= WR }, > + { .hw_value =3D 9, .center_freq =3D 2452, .max_power =3D CC33XX_MAX_TXP= WR }, > + { .hw_value =3D 10, .center_freq =3D 2457, .max_power =3D CC33XX_MAX_TX= PWR }, > + { .hw_value =3D 11, .center_freq =3D 2462, .max_power =3D CC33XX_MAX_TX= PWR }, > + { .hw_value =3D 12, .center_freq =3D 2467, .max_power =3D CC33XX_MAX_TX= PWR }, > + { .hw_value =3D 13, .center_freq =3D 2472, .max_power =3D CC33XX_MAX_TX= PWR }, > +}; > + > +static const struct ieee80211_sband_iftype_data iftype_data_2ghz[] =3D {{ > + .types_mask =3D BIT(NL80211_IFTYPE_STATION), > + .he_cap =3D { > + .has_he =3D true, > + .he_cap_elem =3D { > + .mac_cap_info[0] =3D > + IEEE80211_HE_MAC_CAP0_HTC_HE | > + IEEE80211_HE_MAC_CAP0_TWT_REQ, > + .mac_cap_info[1] =3D > + IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_16US | > + IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_8, > + .mac_cap_info[2] =3D > + IEEE80211_HE_MAC_CAP2_32BIT_BA_BITMAP | > + IEEE80211_HE_MAC_CAP2_ALL_ACK | > + IEEE80211_HE_MAC_CAP2_TRS | > + IEEE80211_HE_MAC_CAP2_BSR | > + IEEE80211_HE_MAC_CAP2_ACK_EN, > + .mac_cap_info[3] =3D > + IEEE80211_HE_MAC_CAP3_OMI_CONTROL | > + IEEE80211_HE_MAC_CAP3_RX_CTRL_FRAME_TO_MULTIBSS, > + .mac_cap_info[4] =3D > + IEEE80211_HE_MAC_CAP4_AMSDU_IN_AMPDU | > + IEEE80211_HE_MAC_CAP4_NDP_FB_REP | > + IEEE80211_HE_MAC_CAP4_MULTI_TID_AGG_TX_QOS_B39, > + .mac_cap_info[5] =3D > + IEEE80211_HE_MAC_CAP5_HT_VHT_TRIG_FRAME_RX, > + .phy_cap_info[0] =3D 0, > + .phy_cap_info[1] =3D > + IEEE80211_HE_PHY_CAP1_DEVICE_CLASS_A | > + IEEE80211_HE_PHY_CAP1_HE_LTF_AND_GI_FOR_HE_PPDUS_0_8US, > + .phy_cap_info[2] =3D > + IEEE80211_HE_PHY_CAP2_NDP_4x_LTF_AND_3_2US, > + .phy_cap_info[3] =3D > + IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_NO_DCM | > + IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_1 | > + IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_16_QAM | > + IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_1, > + .phy_cap_info[4] =3D > + IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE | > + IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_4, > + .phy_cap_info[5] =3D > + IEEE80211_HE_PHY_CAP5_NG16_SU_FEEDBACK | > + IEEE80211_HE_PHY_CAP5_NG16_MU_FEEDBACK, > + .phy_cap_info[6] =3D > + IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_42_SU | > + IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_75_MU | > + IEEE80211_HE_PHY_CAP6_TRIG_SU_BEAMFORMING_FB | > + IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMING_PARTIAL_BW_FB | > + IEEE80211_HE_PHY_CAP6_TRIG_CQI_FB | > + IEEE80211_HE_PHY_CAP6_PARTIAL_BW_EXT_RANGE, > + .phy_cap_info[7] =3D > + IEEE80211_HE_PHY_CAP7_HE_SU_MU_PPDU_4XLTF_AND_08_US_GI, > + .phy_cap_info[8] =3D > + IEEE80211_HE_PHY_CAP8_HE_ER_SU_PPDU_4XLTF_AND_08_US_GI | > + IEEE80211_HE_PHY_CAP8_20MHZ_IN_40MHZ_HE_PPDU_IN_2G | > + IEEE80211_HE_PHY_CAP8_HE_ER_SU_1XLTF_AND_08_US_GI, > + .phy_cap_info[9] =3D > + IEEE80211_HE_PHY_CAP9_NON_TRIGGERED_CQI_FEEDBACK | > + IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_COMP_SIGB | > + IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_NON_COMP_SIGB | > + IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US, > + }, > + /* Set default Tx/Rx HE MCS NSS Support field. > + * Indicate support for up to 2 spatial streams and all > + * MCS, without any special cases > + */ > + .he_mcs_nss_supp =3D { > + .rx_mcs_80 =3D cpu_to_le16(0xfffc), > + .tx_mcs_80 =3D cpu_to_le16(0xfffc), > + .rx_mcs_160 =3D cpu_to_le16(0xffff), > + .tx_mcs_160 =3D cpu_to_le16(0xffff), > + .rx_mcs_80p80 =3D cpu_to_le16(0xffff), > + .tx_mcs_80p80 =3D cpu_to_le16(0xffff), > + }, > + /* Set default PPE thresholds, with PPET16 set to 0, > + * PPET8 set to 7 > + */ > + .ppe_thres =3D {0xff, 0xff, 0xff, 0xff}, > + }, > +}}; > + > +/* can't be const, mac80211 writes to this */ I think that is wrong, cc33xx_init_ieee80211 only does memcpy(..., &cc33xx_band_2ghz, ...) which shouldn't clash with a const. > +static struct ieee80211_supported_band cc33xx_band_2ghz =3D { > + .channels =3D cc33xx_channels, > + .n_channels =3D ARRAY_SIZE(cc33xx_channels), > + .bitrates =3D cc33xx_rates, > + .n_bitrates =3D ARRAY_SIZE(cc33xx_rates), > +}; > + > +/* 5 GHz data rates for cc33xx */ > +static struct ieee80211_rate cc33xx_rates_5ghz[] =3D { > + { .bitrate =3D 60, > + .hw_value =3D CONF_HW_BIT_RATE_6MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_6MBPS, }, > + { .bitrate =3D 90, > + .hw_value =3D CONF_HW_BIT_RATE_9MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_9MBPS, }, > + { .bitrate =3D 120, > + .hw_value =3D CONF_HW_BIT_RATE_12MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_12MBPS, }, > + { .bitrate =3D 180, > + .hw_value =3D CONF_HW_BIT_RATE_18MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_18MBPS, }, > + { .bitrate =3D 240, > + .hw_value =3D CONF_HW_BIT_RATE_24MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_24MBPS, }, > + { .bitrate =3D 360, > + .hw_value =3D CONF_HW_BIT_RATE_36MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_36MBPS, }, > + { .bitrate =3D 480, > + .hw_value =3D CONF_HW_BIT_RATE_48MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_48MBPS, }, > + { .bitrate =3D 540, > + .hw_value =3D CONF_HW_BIT_RATE_54MBPS, > + .hw_value_short =3D CONF_HW_BIT_RATE_54MBPS, }, > +}; > + > +/* 5 GHz band channels for cc33xx */ > +static struct ieee80211_channel cc33xx_channels_5ghz[] =3D { > + { .hw_value =3D 36, .center_freq =3D 5180, .max_power =3D CC33XX_MAX_TX= PWR }, > + { .hw_value =3D 40, .center_freq =3D 5200, .max_power =3D CC33XX_MAX_TX= PWR }, > + { .hw_value =3D 44, .center_freq =3D 5220, .max_power =3D CC33XX_MAX_TX= PWR }, > + { .hw_value =3D 48, .center_freq =3D 5240, .max_power =3D CC33XX_MAX_TX= PWR }, > + { .hw_value =3D 52, .center_freq =3D 5260, .max_power =3D CC33XX_MAX_TX= PWR }, > + { .hw_value =3D 56, .center_freq =3D 5280, .max_power =3D CC33XX_MAX_TX= PWR }, > + { .hw_value =3D 60, .center_freq =3D 5300, .max_power =3D CC33XX_MAX_TX= PWR }, > + { .hw_value =3D 64, .center_freq =3D 5320, .max_power =3D CC33XX_MAX_TX= PWR }, > + { .hw_value =3D 100, .center_freq =3D 5500, .max_power =3D CC33XX_MAX_T= XPWR }, > + { .hw_value =3D 104, .center_freq =3D 5520, .max_power =3D CC33XX_MAX_T= XPWR }, > + { .hw_value =3D 108, .center_freq =3D 5540, .max_power =3D CC33XX_MAX_T= XPWR }, > + { .hw_value =3D 112, .center_freq =3D 5560, .max_power =3D CC33XX_MAX_T= XPWR }, > + { .hw_value =3D 116, .center_freq =3D 5580, .max_power =3D CC33XX_MAX_T= XPWR }, > + { .hw_value =3D 120, .center_freq =3D 5600, .max_power =3D CC33XX_MAX_T= XPWR }, > + { .hw_value =3D 124, .center_freq =3D 5620, .max_power =3D CC33XX_MAX_T= XPWR }, > + { .hw_value =3D 128, .center_freq =3D 5640, .max_power =3D CC33XX_MAX_T= XPWR }, > + { .hw_value =3D 132, .center_freq =3D 5660, .max_power =3D CC33XX_MAX_T= XPWR }, > + { .hw_value =3D 136, .center_freq =3D 5680, .max_power =3D CC33XX_MAX_T= XPWR }, > + { .hw_value =3D 140, .center_freq =3D 5700, .max_power =3D CC33XX_MAX_T= XPWR }, > + { .hw_value =3D 149, .center_freq =3D 5745, .max_power =3D CC33XX_MAX_T= XPWR }, > + { .hw_value =3D 153, .center_freq =3D 5765, .max_power =3D CC33XX_MAX_T= XPWR }, > + { .hw_value =3D 157, .center_freq =3D 5785, .max_power =3D CC33XX_MAX_T= XPWR }, > + { .hw_value =3D 161, .center_freq =3D 5805, .max_power =3D CC33XX_MAX_T= XPWR }, > + { .hw_value =3D 165, .center_freq =3D 5825, .max_power =3D CC33XX_MAX_T= XPWR }, > +}; > + > +static const struct ieee80211_sband_iftype_data iftype_data_5ghz[] =3D {{ > + .types_mask =3D BIT(NL80211_IFTYPE_STATION), > + .he_cap =3D { > + .has_he =3D true, > + .he_cap_elem =3D { > + .mac_cap_info[0] =3D =2Emac_cap_info should have a deeper indention than .he_cap_elem. > + IEEE80211_HE_MAC_CAP0_HTC_HE | > + IEEE80211_HE_MAC_CAP0_TWT_REQ, > + .mac_cap_info[1] =3D > + IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_16US | > + IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_8, > + .mac_cap_info[2] =3D > + IEEE80211_HE_MAC_CAP2_32BIT_BA_BITMAP | > + IEEE80211_HE_MAC_CAP2_ALL_ACK | > + IEEE80211_HE_MAC_CAP2_TRS | > + IEEE80211_HE_MAC_CAP2_BSR | > + IEEE80211_HE_MAC_CAP2_ACK_EN, > + .mac_cap_info[3] =3D > + IEEE80211_HE_MAC_CAP3_OMI_CONTROL | > + IEEE80211_HE_MAC_CAP3_RX_CTRL_FRAME_TO_MULTIBSS, > + .mac_cap_info[4] =3D > + IEEE80211_HE_MAC_CAP4_AMSDU_IN_AMPDU | > + IEEE80211_HE_MAC_CAP4_NDP_FB_REP | > + IEEE80211_HE_MAC_CAP4_MULTI_TID_AGG_TX_QOS_B39, > + .mac_cap_info[5] =3D > + IEEE80211_HE_MAC_CAP5_HT_VHT_TRIG_FRAME_RX, > + .phy_cap_info[0] =3D 0, > + .phy_cap_info[1] =3D > + IEEE80211_HE_PHY_CAP1_DEVICE_CLASS_A | > + IEEE80211_HE_PHY_CAP1_HE_LTF_AND_GI_FOR_HE_PPDUS_0_8US, > + .phy_cap_info[2] =3D > + IEEE80211_HE_PHY_CAP2_NDP_4x_LTF_AND_3_2US, > + .phy_cap_info[3] =3D > + IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_NO_DCM | > + IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_1 | > + IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_16_QAM | > + IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_1, > + .phy_cap_info[4] =3D > + IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE | > + IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_4, > + .phy_cap_info[5] =3D > + IEEE80211_HE_PHY_CAP5_NG16_SU_FEEDBACK | > + IEEE80211_HE_PHY_CAP5_NG16_MU_FEEDBACK, > + .phy_cap_info[6] =3D > + IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_42_SU | > + IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_75_MU | > + IEEE80211_HE_PHY_CAP6_TRIG_SU_BEAMFORMING_FB | > + IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMING_PARTIAL_BW_FB | > + IEEE80211_HE_PHY_CAP6_TRIG_CQI_FB | > + IEEE80211_HE_PHY_CAP6_PARTIAL_BW_EXT_RANGE, > + .phy_cap_info[7] =3D > + IEEE80211_HE_PHY_CAP7_HE_SU_MU_PPDU_4XLTF_AND_08_US_GI, > + .phy_cap_info[8] =3D > + IEEE80211_HE_PHY_CAP8_HE_ER_SU_PPDU_4XLTF_AND_08_US_GI | > + IEEE80211_HE_PHY_CAP8_20MHZ_IN_40MHZ_HE_PPDU_IN_2G | > + IEEE80211_HE_PHY_CAP8_HE_ER_SU_1XLTF_AND_08_US_GI, > + .phy_cap_info[9] =3D > + IEEE80211_HE_PHY_CAP9_NON_TRIGGERED_CQI_FEEDBACK | > + IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_COMP_SIGB | > + IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_NON_COMP_SIGB | > + IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US, > + }, > + /* Set default Tx/Rx HE MCS NSS Support field. > + * Indicate support for up to 2 spatial streams and all > + * MCS, without any special cases > + */ > + .he_mcs_nss_supp =3D { > + .rx_mcs_80 =3D cpu_to_le16(0xfffc), > + .tx_mcs_80 =3D cpu_to_le16(0xfffc), > + .rx_mcs_160 =3D cpu_to_le16(0xffff), > + .tx_mcs_160 =3D cpu_to_le16(0xffff), > + .rx_mcs_80p80 =3D cpu_to_le16(0xffff), > + .tx_mcs_80p80 =3D cpu_to_le16(0xffff), > + }, > + /* Set default PPE thresholds, with PPET16 set to 0, > + * PPET8 set to 7 > + */ > + .ppe_thres =3D {0xff, 0xff, 0xff, 0xff}, > + }, > +}}; > + > +static struct ieee80211_supported_band cc33xx_band_5ghz =3D { > + .channels =3D cc33xx_channels_5ghz, > + .n_channels =3D ARRAY_SIZE(cc33xx_channels_5ghz), > + .bitrates =3D cc33xx_rates_5ghz, > + .n_bitrates =3D ARRAY_SIZE(cc33xx_rates_5ghz), > + .vht_cap =3D { > + .vht_supported =3D true, > + .cap =3D (IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 | (1 << > + IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT)), > + .vht_mcs =3D { > + .rx_mcs_map =3D cpu_to_le16(0xfffc), > + .rx_highest =3D cpu_to_le16(7), > + .tx_mcs_map =3D cpu_to_le16(0xfffc), > + .tx_highest =3D cpu_to_le16(7), > + }, > + }, > +}; > + > +static void __cc33xx_op_remove_interface(struct cc33xx *cc, > + struct ieee80211_vif *vif); > +static void cc33xx_turn_off(struct cc33xx *cc); > +static void cc33xx_free_ap_keys(struct cc33xx_vif *wlvif); > +static int process_core_status(struct cc33xx *cc, > + struct core_status *core_status); > +static int cc33xx_setup(struct cc33xx *cc); > + > +static int cc33xx_set_authorized(struct cc33xx *cc, struct cc33xx_vif *w= lvif) > +{ > + int ret; > + > + if (WARN_ON(wlvif->bss_type !=3D BSS_TYPE_STA_BSS)) > + return -EINVAL; > + > + if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) > + return 0; > + > + if (test_and_set_bit(WLVIF_FLAG_STA_STATE_SENT, &wlvif->flags)) > + return 0; > + > + ret =3D cc33xx_cmd_set_peer_state(cc, wlvif->sta.hlid); > + if (ret < 0) > + return ret; > + > + dev_info(cc->dev, "Association complete.\n"); > + return 0; > +} > + > +static void cc33xx_adjust_conf(struct cc33xx *cc) > +{ > + if (no_recovery !=3D -1) > + cc->conf.core.no_recovery =3D (u8)no_recovery; > +} > + > +void cc33xx_flush_deferred_work(struct cc33xx *cc) > +{ > + struct sk_buff *skb; > + > + /* Pass all received frames to the network stack */ > + while ((skb =3D skb_dequeue(&cc->deferred_rx_queue))) { > + cc33xx_debug(cc->dev, DEBUG_RX, "%s: rx skb 0x%p\n", __func__, skb); > + ieee80211_rx_ni(cc->hw, skb); > + } > + > + /* Return sent skbs to the network stack */ > + while ((skb =3D skb_dequeue(&cc->deferred_tx_queue))) > + ieee80211_tx_status_ni(cc->hw, skb); > +} > + > +static void cc33xx_netstack_work(struct work_struct *work) > +{ > + struct cc33xx *cc =3D container_of(work, struct cc33xx, netstack_work); > + > + do { > + cc33xx_flush_deferred_work(cc); > + } while (skb_queue_len(&cc->deferred_rx_queue)); > +} > + > +static int cc33xx_irq_work(struct cc33xx *cc) > +{ > + int ret =3D 0; > + struct core_status *core_status_ptr; > + u8 *rx_buf_ptr; > + u16 rx_buf_len; > + size_t read_data_len; > + const size_t maximum_rx_packet_size =3D CC33XX_FW_RX_PACKET_RAM; > + size_t rx_byte_count; > + struct nab_rx_header *nab_rx_header; > + > + process_deferred_events(cc); > + > + guard(mutex)(&cc->mutex); > + > + claim_core_status_lock(cc); > + > + rx_byte_count =3D le32_get_bits(cc->core_status->rx_status, RX_BYTE_COU= NT_MASK); > + if (rx_byte_count !=3D 0) { > + const int read_headers_len =3D sizeof(struct core_status) > + + sizeof(struct nab_rx_header); > + > + /* Read aggressively as more data might be coming in */ > + rx_byte_count *=3D 2; > + > + read_data_len =3D rx_byte_count + read_headers_len; > + > + if (cc->max_transaction_len) { /* Used in SPI interface */ > + const int spi_alignment =3D sizeof(u32) - 1; > + > + read_data_len =3D __ALIGN_MASK(read_data_len, > + spi_alignment); > + read_data_len =3D min(read_data_len, > + cc->max_transaction_len); > + } else { /* SDIO */ > + const int sdio_alignment =3D CC33XX_BUS_BLOCK_SIZE - 1; > + > + read_data_len =3D __ALIGN_MASK(read_data_len, > + sdio_alignment); > + read_data_len =3D min(read_data_len, > + maximum_rx_packet_size); > + } > + > + ret =3D cc33xx_raw_read(cc, CC33XX_NAB_DATA_ADDR, cc->aggr_buf, > + read_data_len, true); > + if (ret < 0) { > + release_core_status_lock(cc); > + return ret; > + } > + > + core_status_ptr =3D (struct core_status *)((u8 *)cc->aggr_buf + > + read_data_len - sizeof(struct core_status)); > + > + memcpy(cc->core_status, > + core_status_ptr, sizeof(struct core_status)); > + > + process_core_status(cc, cc->core_status); > + > + release_core_status_lock(cc); > + > + nab_rx_header =3D (struct nab_rx_header *)cc->aggr_buf; > + rx_buf_len =3D le16_to_cpu(nab_rx_header->len) - 8; > + if (rx_buf_len !=3D 0) { > + rx_buf_ptr =3D (u8 *)cc->aggr_buf + sizeof(struct nab_rx_header); > + cc33xx_rx(cc, rx_buf_ptr, rx_buf_len); > + } else { > + dev_err(cc->dev, "Rx buffer length is 0\n"); > + cc33xx_queue_recovery_work(cc); > + } > + } else { > + release_core_status_lock(cc); > + } > + > + cc33xx_tx_immediate_complete(cc); > + > + return ret; > +} > + > +static int read_core_status(struct cc33xx *cc, struct core_status *core_= status) > +{ > + return cc33xx_raw_read(cc, CC33XX_NAB_STATUS_ADDR, core_status, > + sizeof(*core_status), false); > +} > + > +#define CC33XX_CTRL_TYPE_BITS 4 > +static int get_type(struct control_info_descriptor *control_info_descrip= tor) > +{ > + u16 type_mask =3D GENMASK(CC33XX_CTRL_TYPE_BITS - 1, 0); > + > + return le16_get_bits(control_info_descriptor->type_and_length, type_mas= k); > +} > + > +static unsigned int get_length(struct control_info_descriptor *control_i= nfo_descriptor) > +{ > + u16 length_mask =3D GENMASK(15, CC33XX_CTRL_TYPE_BITS); > + > + return le16_get_bits(control_info_descriptor->type_and_length, length_m= ask); > +} > + > +static int parse_control_message(struct cc33xx *cc, > + const u8 *buffer, size_t buffer_length) > +{ > + const u8 *const end_of_payload =3D buffer + buffer_length; > + const u8 *const start_of_payload =3D buffer; > + struct control_info_descriptor *control_info_descriptor; > + const u8 *event_data, *cmd_result_data; > + unsigned int ctrl_info_type, ctrl_info_length; > + > + while (buffer < end_of_payload) { > + control_info_descriptor =3D > + (struct control_info_descriptor *)buffer; > + > + ctrl_info_type =3D get_type(control_info_descriptor); > + ctrl_info_length =3D get_length(control_info_descriptor); > + > + cc33xx_debug(cc->dev, DEBUG_CMD, "Processing message type %d, len %d\n= ", > + ctrl_info_type, ctrl_info_length); > + > + switch (ctrl_info_type) { > + case CTRL_MSG_EVENT: > + event_data =3D buffer + sizeof(*control_info_descriptor); > + > + deffer_event(cc, event_data, ctrl_info_length); > + break; > + > + case CTRL_MSG_COMMND_COMPLETE: > + cmd_result_data =3D buffer; > + cmd_result_data +=3D sizeof(*control_info_descriptor); > + > + if (ctrl_info_length > sizeof(cc->command_result)) { > + print_hex_dump(KERN_DEBUG, "message dump:", > + DUMP_PREFIX_OFFSET, 16, 1, > + cmd_result_data, > + ctrl_info_length, false); > + > + WARN(1, "Error device response exceeds result buffer size\n"); > + return -EIO; > + } > + > + memcpy(cc->command_result, > + cmd_result_data, ctrl_info_length); > + > + cc->result_length =3D ctrl_info_length; > + > + complete(&cc->command_complete); > + break; > + > + default: > + print_hex_dump(KERN_DEBUG, "message dump:", > + DUMP_PREFIX_OFFSET, 16, 1, > + start_of_payload, buffer_length, false); > + > + WARN(1, "Error processing device message @ offset %zu\n", > + (size_t)(buffer - start_of_payload)); > + > + return -EIO; > + } > + > + buffer +=3D sizeof(*control_info_descriptor); > + buffer +=3D ctrl_info_length; > + } > + > + return 0; > +} > + > +static int read_control_message(struct cc33xx *cc, u8 *read_buffer, > + size_t buffer_size) > +{ > + int ret; > + size_t device_message_size; > + struct nab_header *nab_header; > + > + ret =3D cc33xx_raw_read(cc, CC33XX_NAB_CONTROL_ADDR, read_buffer, > + buffer_size, false); > + > + if (ret < 0) { > + cc33xx_debug(cc->dev, DEBUG_CMD, > + "control read Error response 0x%x\n", ret); > + return ret; > + } > + > + nab_header =3D (struct nab_header *)read_buffer; > + > + if (le32_to_cpu(nab_header->sync_pattern) !=3D CC33XX_DEVICE_SYNC_PATTE= RN) { > + dev_err(cc->dev, "Wrong device sync pattern: 0x%x\n", > + nab_header->sync_pattern); > + return -EIO; > + } > + > + device_message_size =3D sizeof(*nab_header) + CC33XX_NAB_EXTRA_BYTES > + + le16_to_cpu(nab_header->len); > + > + if (device_message_size > buffer_size) { > + dev_err(cc->dev, "Invalid NAB length field: %x\n", nab_header->len); > + return -EIO; > + } > + > + return le16_to_cpu(nab_header->len); > +} > + > +static int process_event_and_cmd_result(struct cc33xx *cc, > + struct core_status *core_status) > +{ > + int ret; > + u8 *message; > + const size_t buffer_size =3D CC33XX_CMD_MAX_SIZE; > + size_t message_length; > + struct core_status *new_core_status; > + __le32 previous_hint; > + > + u8 *read_buffer __free(kfree) =3D NULL; > + > + read_buffer =3D kmalloc(buffer_size, GFP_KERNEL); > + if (!read_buffer) > + return -ENOMEM; > + > + ret =3D read_control_message(cc, read_buffer, buffer_size); > + if (ret < 0) > + return ret; > + > + message_length =3D ret - CC33XX_NAB_EXTRA_BYTES; > + message =3D read_buffer + sizeof(struct nab_header) + CC33XX_NAB_EXTRA_= BYTES; > + ret =3D parse_control_message(cc, message, message_length); > + if (ret < 0) > + return ret; > + > + /* Each read transaction always carries an updated core status */ > + previous_hint =3D core_status->host_interrupt_status; > + new_core_status =3D (struct core_status *) > + (read_buffer + buffer_size - sizeof(struct core_status)); > + memcpy(core_status, new_core_status, sizeof(*core_status)); > + /* Host interrupt filed is clear-on-read and we do not want > + * to overrun previously unhandled bits. > + */ > + core_status->host_interrupt_status |=3D previous_hint; > + > + return ret; > +} > + > +static int verify_padding(struct cc33xx *cc) > +{ > + unsigned int i; > + const u32 valid_padding =3D 0x55555555; > + struct core_status *core_status =3D cc->core_status; > + > + for (i =3D 0; i < ARRAY_SIZE(core_status->block_pad); i++) { > + if (le32_to_cpu(core_status->block_pad[i]) !=3D valid_padding) { > + dev_err(cc->dev, "Error in core status padding:\n"); > + print_hex_dump(KERN_DEBUG, "\n", DUMP_PREFIX_OFFSET, 16, > + 1, core_status, sizeof(*core_status), > + false); > + return -1; > + } > + } > + > + return 0; > +} > + > +static int process_core_status(struct cc33xx *cc, > + struct core_status *core_status) > +{ > + bool core_status_idle; > + u32 shadow_host_interrupt_status; > + int ret; > + > + do { > + core_status_idle =3D true; > + > + shadow_host_interrupt_status =3D > + le32_to_cpu(core_status->host_interrupt_status); > + > + /* Interrupts are aggregated (ORed) in this filed with each > + * read operation from the device. > + */ > + core_status->host_interrupt_status =3D 0; > + > + cc33xx_debug(cc->dev, DEBUG_IRQ, > + "HINT_STATUS: 0x%x, TSF: 0x%x, rx status: 0x%x\n", > + shadow_host_interrupt_status, core_status->tsf, > + core_status->rx_status); > + > + if (shadow_host_interrupt_status & HINT_COMMAND_COMPLETE) { > + ret =3D process_event_and_cmd_result(cc, core_status); > + if (ret < 0) { > + memset(core_status, 0, sizeof(*core_status)); > + return ret; > + } > + core_status_idle =3D false; > + } > + > + if (le32_get_bits(core_status->rx_status, RX_BYTE_COUNT_MASK) !=3D 0) > + queue_work(cc->freezable_wq, &cc->irq_deferred_work); > + > + if (core_status->fw_info.tx_result_queue_index !=3D cc->last_fw_rls_id= x) > + queue_work(cc->freezable_wq, &cc->irq_deferred_work); > + > + if (shadow_host_interrupt_status & HINT_NEW_TX_RESULT) > + queue_work(cc->freezable_wq, &cc->irq_deferred_work); > + > + if (shadow_host_interrupt_status & BOOT_TIME_INTERRUPTS) > + cc33xx_handle_boot_irqs(cc, shadow_host_interrupt_status); > + > + if (shadow_host_interrupt_status & HINT_GENERAL_ERROR) { > + dev_err(cc->dev, "FW is stuck, triggering recovery\n"); > + cc33xx_queue_recovery_work(cc); > + } > + } while (!core_status_idle); > + > + return 0; > +} > + > +void cc33xx_irq(void *cookie) > +{ > + struct cc33xx *cc =3D cookie; > + int ret; > + > + claim_core_status_lock(cc); > + > + if (test_bit(CC33XX_FLAG_SUSPENDED, &cc->flags)) { > + /* don't enqueue a work right now. mark it as pending */ > + set_bit(CC33XX_FLAG_PENDING_WORK, &cc->flags); > + scoped_guard(spinlock_irqsave, &cc->cc_lock) { > + cc33xx_disable_interrupts_nosync(cc); > + pm_wakeup_hard_event(cc->dev); > + } > + goto out; > + } > + > + ret =3D read_core_status(cc, cc->core_status); > + if (unlikely(ret < 0)) { > + dev_err(cc->dev, "IO error during core status read\n"); > + cc33xx_queue_recovery_work(cc); > + goto out; > + } > + > + ret =3D verify_padding(cc); > + if (unlikely(ret < 0)) { > + cc33xx_queue_recovery_work(cc); > + goto out; > + } > + > + process_core_status(cc, cc->core_status); > + > +out: > + release_core_status_lock(cc); > +} > + > +struct vif_counter_data { > + u8 counter; > + > + struct ieee80211_vif *cur_vif; > + bool cur_vif_running; > +}; > + > +static void cc33xx_vif_count_iter(void *data, u8 *mac, > + struct ieee80211_vif *vif) > +{ > + struct vif_counter_data *counter =3D data; > + > + counter->counter++; > + if (counter->cur_vif =3D=3D vif) > + counter->cur_vif_running =3D true; > +} > + > +static void cc33xx_get_vif_count(struct ieee80211_hw *hw, > + struct ieee80211_vif *cur_vif, > + struct vif_counter_data *data) > +{ > + memset(data, 0, sizeof(*data)); > + data->cur_vif =3D cur_vif; > + > + ieee80211_iterate_active_interfaces(hw, IEEE80211_IFACE_ITER_RESUME_ALL, > + cc33xx_vif_count_iter, data); > +} > + > +void cc33xx_queue_recovery_work(struct cc33xx *cc) > +{ > + /* Avoid a recursive recovery */ > + if (!test_bit(CC33XX_FLAG_RECOVERY_IN_PROGRESS, &cc->flags)) { > + set_bit(CC33XX_FLAG_RECOVERY_IN_PROGRESS, &cc->flags); > + queue_work(cc->freezable_wq, &cc->recovery_work); > + } > +} > + > +/* save the last used PN in the private part of iee80211_sta, > + * in case of recovery/suspend > + */ > +static void cc33xx_save_freed_pkts(struct cc33xx *cc, u8 hlid, > + struct cc33xx_station *wl_sta) > +{ > + u32 sqn_recovery_padding =3D CC33XX_TX_SQN_POST_RECOVERY_PADDING; > + > + wl_sta->total_freed_pkts =3D cc->links[hlid].total_freed_pkts; > + > + /* increment the initial seq number on recovery to account for > + * transmitted packets that we haven't yet got in the FW status > + */ > + if (test_bit(CC33XX_FLAG_RECOVERY_IN_PROGRESS, &cc->flags)) > + wl_sta->total_freed_pkts +=3D sqn_recovery_padding; > +} > + > +static void cc33xx_free_wlsta_info(struct cc33xx *cc, > + struct cc33xx_vif *wlvif, > + u8 hlid, const u8 *addr) > +{ > + struct ieee80211_sta *sta; > + struct ieee80211_vif *vif =3D cc33xx_wlvif_to_vif(wlvif); > + > + if (WARN_ON(hlid =3D=3D CC33XX_INVALID_LINK_ID || > + is_zero_ether_addr(addr))) > + return; > + > + rcu_read_lock(); > + sta =3D ieee80211_find_sta(vif, addr); > + > + if (sta) { > + struct cc33xx_station *wl_sta =3D (void *)sta->drv_priv; > + > + /* In case of recovery, clear the in_connection details, since > + * HW restart will re-add them for the same states. > + */ > + if (test_bit(CC33XX_FLAG_RECOVERY_IN_PROGRESS, &cc->flags)) > + cc33xx_update_inconn_sta(cc, wlvif, wl_sta, false); > + > + cc33xx_save_freed_pkts(cc, hlid, wl_sta); > + } > + > + rcu_read_unlock(); > +} > + > +static void cc33xx_recovery_work(struct work_struct *work) > +{ > + struct cc33xx *cc =3D container_of(work, struct cc33xx, recovery_work); > + struct cc33xx_vif *wlvif; > + struct ieee80211_vif *vif; > + > + dev_notice(cc->dev, "CC33xx driver attempting recovery\n"); > + > + if (cc->conf.core.no_recovery) { > + dev_info(cc->dev, "Recovery disabled by configuration, driver will not= restart.\n"); > + return; > + } > + > + if (test_bit(CC33XX_FLAG_DRIVER_REMOVED, &cc->flags)) { > + dev_info(cc->dev, "Driver being removed, recovery disabled\n"); > + return; > + } > + > + if (!cc->mac80211_registered) { > + dev_err(cc->dev, "Fatal error during driver init, cannot recover\n"); > + cc->state =3D CC33XX_STATE_OFF; > + cc33xx_disable_interrupts_nosync(cc); > + return; > + } > + > + set_bit(CC33XX_FLAG_RECOVERY_IN_PROGRESS, &cc->flags); > + > + wiphy_lock(cc->hw->wiphy); > + > + scoped_guard(mutex, &cc->mutex) > + cc->state =3D CC33XX_STATE_RESTARTING; > + > + while (!list_empty(&cc->wlvif_list)) { > + wlvif =3D list_first_entry(&cc->wlvif_list, > + struct cc33xx_vif, list); > + vif =3D cc33xx_wlvif_to_vif(wlvif); > + > + if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) > + ieee80211_connection_loss(vif); > + > + __cc33xx_op_remove_interface(cc, vif); > + } > + wiphy_unlock(cc->hw->wiphy); > + > + cc33xx_turn_off(cc); > + msleep(500); > + > + if (!cc33xx_init_fw(cc)) > + ieee80211_restart_hw(cc->hw); > + > + clear_bit(CC33XX_FLAG_RECOVERY_IN_PROGRESS, &cc->flags); > + > + dev_notice(cc->dev, "CC33xx driver recovery complete\n"); > +} > + > +static void irq_deferred_work(struct work_struct *work) > +{ > + int ret; > + struct cc33xx *cc =3D > + container_of(work, struct cc33xx, irq_deferred_work); > + > + ret =3D cc33xx_irq_work(cc); > + if (ret) > + cc33xx_queue_recovery_work(cc); > +} > + > +static void irq_wrapper(struct platform_device *pdev) > +{ > + struct cc33xx *cc =3D platform_get_drvdata(pdev); > + > + cc33xx_irq(cc); > +} > + > +static int cc33xx_plt_init(struct cc33xx *cc) > +{ > + /* PLT init: Role enable + Role start + plt Init */ > + int ret =3D 0; > + > + /* Role enable */ > + u8 returned_role_id =3D CC33XX_INVALID_ROLE_ID; > + > + ret =3D cc33xx_cmd_role_enable(cc, bcast_addr, > + ROLE_TRANSCEIVER, &returned_role_id); > + if (ret < 0) { > + dev_info(cc->dev, "PLT init Role Enable FAILED! , PLT roleID is: %u\n", > + returned_role_id); > + return ret; > + } > + > + ret =3D cc33xx_cmd_role_start_transceiver(cc, returned_role_id); > + if (ret < 0) { > + dev_info(cc->dev, "PLT init Role Start FAILED! , PLT roleID is: %u\n", > + returned_role_id); > + cc33xx_cmd_role_disable(cc, &returned_role_id); > + return ret; > + } > + > + cc->plt_role_id =3D returned_role_id; > + ret =3D cc33xx_cmd_plt_enable(cc); > + > + if (ret >=3D 0) > + dev_info(cc->dev, "PLT init Role Start succeed!, PLT roleID is: %u\n", > + returned_role_id); > + else > + dev_info(cc->dev, "PLT init Role Start FAILED! , PLT roleID is: %u\n", > + returned_role_id); > + > + return ret; > +} > + > +int cc33xx_plt_start(struct cc33xx *cc, const enum plt_mode plt_mode) > +{ > + int ret =3D 0; > + > + if (plt_mode =3D=3D PLT_ON && cc->plt_mode =3D=3D PLT_ON) { > + dev_err(cc->dev, "PLT already on\n"); > + return ret; > + } > + > + dev_notice(cc->dev, "PLT start\n"); > + > + if (plt_mode !=3D PLT_CHIP_AWAKE) { > + ret =3D cc33xx_plt_init(cc); > + if (ret < 0) { > + dev_err(cc->dev, "PLT start failed\n"); > + return ret; > + } > + } > + > + /* Indicate to lower levels that we are now in PLT mode */ > + cc->plt =3D true; > + cc->plt_mode =3D plt_mode; > + > + return ret; > +} > + > +int cc33xx_plt_stop(struct cc33xx *cc) > +{ > + int ret =3D 0; > + > + dev_notice(cc->dev, "PLT stop\n"); > + > + ret =3D cc33xx_cmd_role_stop_transceiver(cc); > + if (ret < 0) > + return ret; > + > + ret =3D cc33xx_cmd_role_disable(cc, &cc->plt_role_id); > + if (ret < 0) > + return ret; > + > + cc33xx_cmd_plt_disable(cc); > + > + cc33xx_flush_deferred_work(cc); > + > + flush_deferred_event_list(cc); > + > + cc->plt =3D false; > + cc->plt_mode =3D PLT_OFF; > + cc->rx_counter =3D 0; > + > + return ret; > +} > + > +static void cc33xx_op_tx(struct ieee80211_hw *hw, > + struct ieee80211_tx_control *control, > + struct sk_buff *skb) > +{ > + struct cc33xx *cc =3D hw->priv; > + struct ieee80211_tx_info *info =3D IEEE80211_SKB_CB(skb); > + struct ieee80211_vif *vif =3D info->control.vif; > + struct cc33xx_vif *wlvif =3D NULL; > + u8 hlid; > + > + if (!vif) { > + ieee80211_free_txskb(hw, skb); > + return; > + } > + > + guard(spinlock_irqsave)(&cc->cc_lock); > + > + wlvif =3D cc33xx_vif_to_data(vif); > + > + hlid =3D cc33xx_tx_get_hlid(cc, wlvif, skb, control->sta); > + > + /* drop the packet if the link is invalid */ > + if (hlid =3D=3D CC33XX_INVALID_LINK_ID || > + !test_bit(hlid, wlvif->links_map)) { > + cc33xx_debug(cc->dev, DEBUG_TX, "DROP skb hlid %d\n", hlid); > + ieee80211_free_txskb(hw, skb); > + return; > + } > + > + cc33xx_debug(cc->dev, DEBUG_TX, "queue skb hlid %d len %d %p\n", > + hlid, skb->len, skb); > + skb_queue_tail(&cc->links[hlid].tx_pending, skb); > + > + if (!test_bit(CC33XX_FLAG_FW_TX_BUSY, &cc->flags) && > + !test_bit(CC33XX_FLAG_TX_STOPPED, &cc->flags)) { > + cc33xx_debug(cc->dev, DEBUG_TX, "op_tx - Triggering tx thread\n"); > + ieee80211_queue_work(cc->hw, &cc->tx_work); > + } else { > + set_bit(CC33XX_FLAG_TX_PENDING, &cc->flags); > + cc33xx_debug(cc->dev, DEBUG_TX, "op_tx - Not triggering tx thread cc->= flags 0x%lx\n", > + cc->flags); > + } > +} > + > +static void cc33xx_handle_wake_tx_queue(struct ieee80211_hw *hw, > + struct ieee80211_txq *txq) > +{ > + struct cc33xx *cc =3D hw->priv; > + > + if (!test_bit(CC33XX_FLAG_FW_TX_BUSY, &cc->flags) && > + !test_bit(CC33XX_FLAG_TX_STOPPED, &cc->flags)) { > + cc33xx_debug(cc->dev, DEBUG_TX, "wake_txq - Triggering tx thread\n"); > + ieee80211_queue_work(cc->hw, &cc->tx_work); > + } else { > + set_bit(CC33XX_FLAG_TX_PENDING, &cc->flags); > + cc33xx_debug(cc->dev, DEBUG_TX, "wake_txq - Not triggering tx thread c= c->flags 0x%lx\n", > + cc->flags); > + } > +} > + > +static int cc33xx_validate_wowlan_pattern(struct cc33xx *cc, struct cfg8= 0211_pkt_pattern *p) > +{ > + int num_fields =3D 0, in_field =3D 0, fields_size =3D 0; > + int i, pattern_len =3D 0; > + > + if (!p->mask) { > + dev_warn(cc->dev, "No mask in WoWLAN pattern\n"); > + return -EINVAL; > + } > + > + /* The pattern is broken up into segments of bytes at different offsets > + * that need to be checked by the FW filter. Each segment is called > + * a field in the FW API. We verify that the total number of fields > + * required for this pattern won't exceed FW limits (8) > + * as well as the total fields buffer won't exceed the FW limit. > + * Note that if there's a pattern which crosses Ethernet/IP header > + * boundary a new field is required. > + */ > + for (i =3D 0; i < p->pattern_len; i++) { > + if (test_bit(i, (unsigned long *)p->mask)) { > + if (!in_field) { > + in_field =3D 1; > + pattern_len =3D 1; > + } else if (i =3D=3D ETH_HLEN) { > + num_fields++; > + fields_size +=3D pattern_len + > + RX_FILTER_FIELD_OVERHEAD; > + pattern_len =3D 1; > + } else { > + pattern_len++; > + } > + } else if (in_field) { > + in_field =3D 0; > + fields_size +=3D pattern_len + RX_FILTER_FIELD_OVERHEAD; > + num_fields++; > + } > + } > + > + if (in_field) { > + fields_size +=3D pattern_len + RX_FILTER_FIELD_OVERHEAD; > + num_fields++; > + } > + > + if (num_fields > CC33XX_RX_FILTER_MAX_FIELDS) { > + dev_warn(cc->dev, "RX Filter too complex. Too many segments\n"); > + return -EINVAL; > + } > + > + if (fields_size > RX_FILTER_MAX_FIELDS_SIZE) { > + dev_warn(cc->dev, "RX filter pattern is too big\n"); > + return -E2BIG; > + } > + > + return 0; > +} > + > +static void cc33xx_rx_filter_free(struct cc33xx_rx_filter *filter) > +{ > + int i; > + > + if (!filter) > + return; > + > + for (i =3D 0; i < filter->num_fields; i++) > + kfree(filter->fields[i].pattern); > + > + kfree(filter); > +} > + > +static int cc33xx_rx_filter_alloc_field(struct cc33xx_rx_filter *filter, > + u16 offset, u8 flags, > + const u8 *pattern, u8 len) > +{ > + struct cc33xx_rx_filter_field *field; > + > + if (filter->num_fields =3D=3D CC33XX_RX_FILTER_MAX_FIELDS) { > + pr_warn("cc33xx: Max fields per RX filter. can't alloc another\n"); > + return -EINVAL; > + } > + > + field =3D &filter->fields[filter->num_fields]; > + > + field->pattern =3D kzalloc(len, GFP_KERNEL); > + if (!field->pattern) > + return -ENOMEM; > + > + filter->num_fields++; > + > + field->offset =3D cpu_to_le16(offset); > + field->flags =3D flags; > + field->len =3D len; > + memcpy(field->pattern, pattern, len); > + > + return 0; > +} > + > +/* Allocates an RX filter returned through f > + * which needs to be freed using rx_filter_free() > + */ > +static struct cc33xx_rx_filter * > +cc33xx_convert_wowlan_pattern_to_rx_filter(struct cfg80211_pkt_pattern *= p) > +{ > + int i, j, ret =3D 0; > + struct cc33xx_rx_filter *filter; > + u16 offset; > + u8 flags, len; > + > + filter =3D kzalloc_obj(*filter); > + if (!filter) > + return ERR_PTR(-ENOMEM); > + > + i =3D 0; > + while (i < p->pattern_len) { > + if (!test_bit(i, (unsigned long *)p->mask)) { > + i++; > + continue; > + } > + > + for (j =3D i; j < p->pattern_len; j++) { > + if (!test_bit(j, (unsigned long *)p->mask)) > + break; > + > + if (i < ETH_HLEN && > + j >=3D ETH_HLEN) > + break; > + } > + > + if (i < ETH_HLEN) { > + offset =3D i; > + flags =3D CC33XX_RX_FILTER_FLAG_ETHERNET_HEADER; > + } else { > + offset =3D i - ETH_HLEN; > + flags =3D CC33XX_RX_FILTER_FLAG_IP_HEADER; > + } > + > + len =3D j - i; > + > + ret =3D cc33xx_rx_filter_alloc_field(filter, offset, flags, > + &p->pattern[i], len); > + if (ret) { > + cc33xx_rx_filter_free(filter); > + return ERR_PTR(ret); > + } > + > + i =3D j; > + } > + filter->action =3D FILTER_SIGNAL; > + > + return filter; > +} > + > +static int cc33xx_configure_wowlan(struct cc33xx *cc, > + struct cfg80211_wowlan *wow) > +{ > + int i, ret; > + > + if (!wow || (!wow->any && !wow->n_patterns)) { > + if (wow) > + dev_warn(cc->dev, "invalid wow configuration - set to pattern trigger= without setting pattern\n"); > + > + ret =3D cc33xx_acx_default_rx_filter_enable(cc, 0, > + FILTER_SIGNAL); > + if (ret) > + return ret; > + > + ret =3D cc33xx_rx_filter_clear_all(cc); > + if (ret) > + return ret; > + > + return 0; > + } > + > + if (wow->any) { > + ret =3D cc33xx_acx_default_rx_filter_enable(cc, 1, > + FILTER_SIGNAL); > + if (ret) > + return ret; > + > + ret =3D cc33xx_rx_filter_clear_all(cc); > + if (ret) > + return ret; > + > + return 0; > + } > + > + if (WARN_ON(wow->n_patterns > CC33XX_MAX_RX_FILTERS)) > + return -EINVAL; > + > + /* Validate all incoming patterns before clearing current FW state */ > + for (i =3D 0; i < wow->n_patterns; i++) { > + ret =3D cc33xx_validate_wowlan_pattern(cc, &wow->patterns[i]); > + if (ret) { > + dev_warn(cc->dev, "Bad wowlan pattern %d\n", i); > + return ret; > + } > + } > + > + ret =3D cc33xx_acx_default_rx_filter_enable(cc, 0, FILTER_SIGNAL); > + if (ret) > + return ret; > + > + ret =3D cc33xx_rx_filter_clear_all(cc); > + if (ret) > + return ret; > + > + /* Translate WoWLAN patterns into filters */ > + for (i =3D 0; i < wow->n_patterns; i++) { > + struct cfg80211_pkt_pattern *p; > + struct cc33xx_rx_filter *filter =3D NULL; > + > + p =3D &wow->patterns[i]; > + > + filter =3D cc33xx_convert_wowlan_pattern_to_rx_filter(p); > + if (IS_ERR(filter)) { > + dev_warn(cc->dev, "Failed to create an RX filter from wowlan pattern = %d\n", > + i); > + return PTR_ERR(filter); > + } > + > + ret =3D cc33xx_rx_filter_enable(cc, i, 1, filter); > + > + cc33xx_rx_filter_free(filter); > + if (ret) > + return ret; > + } > + > + ret =3D cc33xx_acx_default_rx_filter_enable(cc, 1, FILTER_DROP); > + > + return ret; > +} > + > +static int cc33xx_configure_suspend_sta(struct cc33xx *cc, > + struct cc33xx_vif *wlvif, > + struct cfg80211_wowlan *wow) > +{ > + struct cc33xx_core_conf *core_conf =3D &cc->conf.core; > + int ret =3D 0; > + > + if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) > + return 0; > + > + ret =3D cc33xx_configure_wowlan(cc, wow); > + if (ret < 0) > + return ret; > + > + if (core_conf->suspend_wake_up_event =3D=3D core_conf->wake_up_event && > + core_conf->suspend_listen_interval =3D=3D core_conf->listen_interva= l) > + return ret; > + > + ret =3D cc33xx_acx_wake_up_conditions(cc, core_conf->suspend_wake_up_ev= ent, > + core_conf->suspend_listen_interval); > + if (ret < 0) > + dev_err(cc->dev, "suspend: set wake up conditions failed: %d\n", ret); > + > + return ret; > +} > + > +static int cc33xx_configure_suspend_ap(struct cc33xx *cc, > + struct cc33xx_vif *wlvif, > + struct cfg80211_wowlan *wow) > +{ > + int ret; > + > + if (!test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) > + return 0; > + > + ret =3D cc33xx_acx_beacon_filter_opt(cc, wlvif, true); > + if (ret < 0) > + return ret; > + > + ret =3D cc33xx_configure_wowlan(cc, wow); > + if (ret < 0) > + return ret; > + > + return 0; > +} > + > +static int cc33xx_configure_suspend(struct cc33xx *cc, struct cc33xx_vif= *wlvif, > + struct cfg80211_wowlan *wow) > +{ > + if (wlvif->bss_type =3D=3D BSS_TYPE_STA_BSS) > + return cc33xx_configure_suspend_sta(cc, wlvif, wow); > + > + if (wlvif->bss_type =3D=3D BSS_TYPE_AP_BSS) > + return cc33xx_configure_suspend_ap(cc, wlvif, wow); > + > + return 0; > +} > + > +static void cc33xx_configure_resume(struct cc33xx *cc, struct cc33xx_vif= *wlvif) > +{ > + int ret =3D 0; > + bool is_ap =3D wlvif->bss_type =3D=3D BSS_TYPE_AP_BSS; > + bool is_sta =3D wlvif->bss_type =3D=3D BSS_TYPE_STA_BSS; > + struct cc33xx_core_conf *core_conf =3D &cc->conf.core; > + > + if (!is_ap && !is_sta) > + return; > + > + if ((is_sta && !test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) || > + (is_ap && !test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags))) > + return; > + > + cc33xx_configure_wowlan(cc, NULL); > + > + if (is_sta) { > + if (core_conf->suspend_wake_up_event =3D=3D core_conf->wake_up_event && > + core_conf->suspend_listen_interval =3D=3D core_conf->listen_interv= al) > + return; > + > + ret =3D cc33xx_acx_wake_up_conditions(cc, core_conf->wake_up_event, > + core_conf->listen_interval); > + > + if (ret < 0) > + dev_err(cc->dev, "resume: wake up conditions failed: %d\n", > + ret); > + > + } else if (is_ap) { > + cc33xx_acx_beacon_filter_opt(cc, wlvif, false); > + } > +} > + > +static int __maybe_unused cc33xx_op_suspend(struct ieee80211_hw *hw, > + struct cfg80211_wowlan *wow) > +{ > + struct cc33xx *cc =3D hw->priv; > + struct cc33xx_vif *wlvif; > + int ret =3D 0; > + > + WARN_ON(!wow); > + > + /* we want to perform the recovery before suspending */ > + if (test_bit(CC33XX_FLAG_RECOVERY_IN_PROGRESS, &cc->flags)) { > + dev_warn(cc->dev, "postponing suspend to perform recovery\n"); > + return -EBUSY; > + } > + > + cc->keep_device_power =3D true; > + cc33xx_for_each_wlvif(cc, wlvif) { > + if (cc33xx_is_p2p_mgmt(wlvif)) > + continue; > + > + ret =3D cc33xx_configure_suspend(cc, wlvif, wow); > + if (ret < 0) { > + dev_warn(cc->dev, "couldn't prepare device to suspend\n"); > + return ret; > + } > + } > + > + if (ret < 0) { > + dev_warn(cc->dev, "couldn't prepare device to suspend\n"); > + return ret; > + } > + > + flush_work(&cc->tx_work); > + > + /* set suspended flag to avoid triggering a new threaded_irq > + * work. > + */ > + scoped_guard(spinlock_irqsave, &cc->cc_lock) > + set_bit(CC33XX_FLAG_SUSPENDED, &cc->flags); > + > + return 0; > +} > + > +static int __maybe_unused cc33xx_op_resume(struct ieee80211_hw *hw) > +{ > + struct cc33xx *cc =3D hw->priv; > + struct cc33xx_vif *wlvif; > + bool run_irq_work =3D false, pending_recovery; > + > + WARN_ON(!cc->keep_device_power); > + > + /* re-enable irq_work enqueuing, and call irq_work directly if > + * there is a pending work. > + */ > + scoped_guard(spinlock_irqsave, &cc->cc_lock) { > + clear_bit(CC33XX_FLAG_SUSPENDED, &cc->flags); > + run_irq_work =3D test_and_clear_bit(CC33XX_FLAG_PENDING_WORK, &cc->fla= gs); > + } > + > + /* test the recovery flag before calling any SDIO functions */ > + pending_recovery =3D test_bit(CC33XX_FLAG_RECOVERY_IN_PROGRESS, > + &cc->flags); > + > + if (run_irq_work) { > + cc33xx_debug(cc->dev, DEBUG_MAC80211, "Running postponed irq_work\n"); > + > + /* don't talk to the HW if recovery is pending */ > + if (!pending_recovery) > + queue_work(cc->freezable_wq, &cc->irq_deferred_work); > + > + cc33xx_enable_interrupts(cc); > + } > + > + if (pending_recovery) { > + dev_warn(cc->dev, "queuing forgotten recovery on resume\n"); > + queue_work(cc->freezable_wq, &cc->recovery_work); > + goto out; > + } > + > + cc33xx_for_each_wlvif(cc, wlvif) { > + if (cc33xx_is_p2p_mgmt(wlvif)) > + continue; > + > + cc33xx_configure_resume(cc, wlvif); > + } > + > +out: > + cc->keep_device_power =3D false; > + > + /* Set a flag to re-init the watchdog on the first Tx after resume. > + * That way we avoid possible conditions where Tx-complete interrupts > + * fail to arrive and we perform a spurious recovery. > + */ > + set_bit(CC33XX_FLAG_REINIT_TX_WDOG, &cc->flags); > + > + return 0; > +} > + > +static int cc33xx_op_start(struct ieee80211_hw *hw) > +{ > + /* We have to delay the booting of the hardware because > + * we need to know the local MAC address before downloading and > + * initializing the firmware. The MAC address cannot be changed > + * after boot, and without the proper MAC address, the firmware > + * will not function properly. > + * > + * The MAC address is first known when the corresponding interface > + * is added. That is where we will initialize the hardware. > + */ > + > + return 0; > +} > + > +static void cc33xx_turn_off(struct cc33xx *cc) > +{ > + int i; > + > + if (cc->state =3D=3D CC33XX_STATE_OFF) { > + if (test_and_clear_bit(CC33XX_FLAG_RECOVERY_IN_PROGRESS, > + &cc->flags)) > + cc33xx_enable_interrupts(cc); > + > + return; > + } > + > + wiphy_lock(cc->hw->wiphy); > + mutex_lock(&cc->mutex); > + > + /* this must be before the cancel_work calls below, so that the work > + * functions don't perform further work. > + */ > + cc->state =3D CC33XX_STATE_OFF; > + > + /* Use the nosync variant to disable interrupts, so the mutex could be > + * held while doing so without deadlocking. > + */ > + cc33xx_disable_interrupts_nosync(cc); > + > + wiphy_delayed_work_cancel(cc->hw->wiphy, &cc->scan_complete_work); > + > + mutex_unlock(&cc->mutex); > + wiphy_unlock(cc->hw->wiphy); > + > + if (!test_bit(CC33XX_FLAG_RECOVERY_IN_PROGRESS, &cc->flags)) > + cancel_work_sync(&cc->recovery_work); > + cc33xx_flush_deferred_work(cc); > + cancel_work_sync(&cc->netstack_work); > + cancel_work_sync(&cc->tx_work); > + cancel_work_sync(&cc->irq_deferred_work); > + > + /* let's notify MAC80211 about the remaining pending TX frames */ > + mutex_lock(&cc->mutex); > + cc33xx_tx_reset(cc); > + > + cc33xx_power_off(cc); > + > + cc->rx_counter =3D 0; > + cc->tx_blocks_available =3D 0; > + cc->tx_allocated_blocks =3D 0; > + > + cc->sleep_auth =3D CC33XX_PSM_ILLEGAL; > + cc->ba_rx_session_count =3D 0; > + memset(cc->roles_map, 0, sizeof(cc->roles_map)); > + memset(cc->links_map, 0, sizeof(cc->links_map)); > + memset(cc->roc_map, 0, sizeof(cc->roc_map)); > + memset(cc->session_ids, 0, sizeof(cc->session_ids)); > + memset(cc->rx_filter_enabled, 0, sizeof(cc->rx_filter_enabled)); > + cc->active_sta_count =3D 0; > + cc->active_link_count =3D 0; > + cc->ble_enable =3D 0; > + > + /* The system link is always allocated */ > + cc->links[CC33XX_SYSTEM_HLID].allocated_pkts =3D 0; > + cc->links[CC33XX_SYSTEM_HLID].prev_freed_pkts =3D 0; > + __set_bit(CC33XX_SYSTEM_HLID, cc->links_map); > + > + /* this is performed after the cancel_work calls and the associated > + * mutex_lock, so that cc33xx_op_add_interface does not accidentally > + * get executed before all these vars have been reset. > + */ > + cc->flags =3D 0; > + > + for (i =3D 0; i < NUM_TX_QUEUES; i++) > + cc->tx_allocated_pkts[i] =3D 0; > + > + kfree(cc->target_mem_map); > + cc->target_mem_map =3D NULL; > + > + mutex_unlock(&cc->mutex); > +} > + > +static void cc33xx_op_stop(struct ieee80211_hw *hw, bool suspend) {} > + > +static void cc33xx_channel_switch_work(struct wiphy *wiphy, > + struct wiphy_work *work) > + > +{ > + struct cc33xx *cc; > + struct ieee80211_vif *vif; > + struct cc33xx_vif *wlvif; > + > + wlvif =3D container_of(work, struct cc33xx_vif, channel_switch_work.wor= k); > + cc =3D wlvif->cc; > + > + dev_info(cc->dev, "channel switch failed (role_id: %d).\n", wlvif->role= _id); > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) > + return; > + > + /* check the channel switch is still ongoing */ > + if (!test_and_clear_bit(WLVIF_FLAG_CS_PROGRESS, &wlvif->flags)) > + return; > + > + vif =3D cc33xx_wlvif_to_vif(wlvif); > + ieee80211_chswitch_done(vif, false, 0); > + > + cc33xx_cmd_stop_channel_switch(cc, wlvif); > +} > + > +static void cc33xx_connection_loss_work(struct wiphy *wiphy, > + struct wiphy_work *work) > + > +{ > + struct cc33xx *cc; > + struct ieee80211_vif *vif; > + struct cc33xx_vif *wlvif; > + > + wlvif =3D container_of(work, struct cc33xx_vif, > + connection_loss_work.work); > + cc =3D wlvif->cc; > + > + dev_info(cc->dev, "Connection loss work (role_id: %d).\n", wlvif->role_= id); > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) > + return; > + > + /* Call mac80211 connection loss */ > + if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) > + return; > + > + vif =3D cc33xx_wlvif_to_vif(wlvif); > + ieee80211_connection_loss(vif); > +} > + > +static void cc33xx_roc_timeout_work(struct wiphy *wiphy, > + struct wiphy_work *work) > +{ > + struct cc33xx *cc; > + struct cc33xx_vif *wlvif; > + > + wlvif =3D container_of(work, struct cc33xx_vif, roc_timeout_work.work); > + cc =3D wlvif->cc; > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) > + return; > + > + if (test_bit(wlvif->role_id, cc->roc_map)) > + cc33xx_croc(cc, wlvif->role_id); > +} > + > +static int cc33xx_allocate_rate_policy(struct cc33xx *cc, u8 *idx) > +{ > + u8 policy =3D find_first_zero_bit(cc->rate_policies_map, > + CC33XX_MAX_RATE_POLICIES); > + if (policy >=3D CC33XX_MAX_RATE_POLICIES) > + return -EBUSY; > + > + __set_bit(policy, cc->rate_policies_map); > + *idx =3D policy; > + return 0; > +} > + > +static void cc33xx_free_rate_policy(struct cc33xx *cc, u8 *idx) > +{ > + if (WARN_ON(*idx >=3D CC33XX_MAX_RATE_POLICIES)) > + return; > + > + __clear_bit(*idx, cc->rate_policies_map); > + *idx =3D CC33XX_MAX_RATE_POLICIES; > +} > + > +static u8 cc33xx_get_role_type(struct cc33xx_vif *wlvif) > +{ > + struct ieee80211_vif *vif =3D cc33xx_wlvif_to_vif(wlvif); > + > + switch (wlvif->bss_type) { > + case BSS_TYPE_AP_BSS: > + if (wlvif->p2p) > + return CC33XX_ROLE_P2P_GO; > + else if (ieee80211_vif_is_mesh(vif)) > + return CC33XX_ROLE_MESH_POINT; > + return CC33XX_ROLE_AP; > + > + case BSS_TYPE_STA_BSS: > + if (wlvif->p2p) > + return CC33XX_ROLE_P2P_CL; > + return CC33XX_ROLE_STA; > + default: > + dev_err(wlvif->cc->dev, "invalid bss_type: %d\n", wlvif->bss_type); > + } > + return CC33XX_INVALID_ROLE_TYPE; > +} > + > +static int cc33xx_init_vif_data(struct cc33xx *cc, struct ieee80211_vif = *vif) > +{ > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + struct conf_tx_settings *tx_settings =3D &cc->conf.host_conf.tx; > + int i; > + > + /* clear everything but the persistent data */ > + memset(wlvif, 0, offsetof(struct cc33xx_vif, persistent)); > + > + switch (ieee80211_vif_type_p2p(vif)) { > + case NL80211_IFTYPE_P2P_CLIENT: > + wlvif->p2p =3D 1; > + fallthrough; > + case NL80211_IFTYPE_STATION: > + case NL80211_IFTYPE_P2P_DEVICE: > + wlvif->bss_type =3D BSS_TYPE_STA_BSS; > + break; > + case NL80211_IFTYPE_P2P_GO: > + wlvif->p2p =3D 1; > + fallthrough; > + case NL80211_IFTYPE_AP: > + case NL80211_IFTYPE_MESH_POINT: > + wlvif->bss_type =3D BSS_TYPE_AP_BSS; > + break; > + default: > + wlvif->bss_type =3D MAX_BSS_TYPE; > + return -EOPNOTSUPP; > + } > + > + wlvif->role_id =3D CC33XX_INVALID_ROLE_ID; > + wlvif->dev_role_id =3D CC33XX_INVALID_ROLE_ID; > + wlvif->dev_hlid =3D CC33XX_INVALID_LINK_ID; > + > + if (wlvif->bss_type =3D=3D BSS_TYPE_STA_BSS) { > + /* init sta data */ > + wlvif->sta.hlid =3D CC33XX_INVALID_LINK_ID; > + cc33xx_allocate_rate_policy(cc, &wlvif->sta.basic_rate_idx); > + cc33xx_allocate_rate_policy(cc, &wlvif->sta.ap_rate_idx); > + cc33xx_allocate_rate_policy(cc, &wlvif->sta.p2p_rate_idx); > + wlvif->basic_rate_set =3D CONF_TX_RATE_MASK_BASIC; > + wlvif->basic_rate =3D CONF_TX_RATE_MASK_BASIC; > + wlvif->rate_set =3D CONF_TX_RATE_MASK_BASIC; > + } else { > + /* init ap data */ > + wlvif->ap.bcast_hlid =3D CC33XX_INVALID_LINK_ID; > + wlvif->ap.global_hlid =3D CC33XX_INVALID_LINK_ID; > + cc33xx_allocate_rate_policy(cc, &wlvif->ap.mgmt_rate_idx); > + cc33xx_allocate_rate_policy(cc, &wlvif->ap.bcast_rate_idx); > + for (i =3D 0; i < CONF_TX_MAX_AC_COUNT; i++) > + cc33xx_allocate_rate_policy(cc, > + &wlvif->ap.ucast_rate_idx[i]); > + wlvif->basic_rate_set =3D CONF_TX_ENABLED_RATES; > + /* TODO: check if basic_rate shouldn't be > + * cc33xx_tx_min_rate_get(cc, wlvif->basic_rate_set); > + * instead (the same thing for STA above). > + */ > + wlvif->basic_rate =3D CONF_TX_ENABLED_RATES; > + /* TODO: this seems to be used only for STA, check it */ > + wlvif->rate_set =3D CONF_TX_ENABLED_RATES; > + } > + > + wlvif->bitrate_masks[NL80211_BAND_2GHZ] =3D tx_settings->basic_rate; > + wlvif->bitrate_masks[NL80211_BAND_5GHZ] =3D tx_settings->basic_rate_5; > + wlvif->beacon_int =3D CC33XX_DEFAULT_BEACON_INT; > + wlvif->power_level =3D CC33XX_MAX_TXPWR; > + > + wiphy_delayed_work_init(&wlvif->channel_switch_work, > + cc33xx_channel_switch_work); > + wiphy_delayed_work_init(&wlvif->connection_loss_work, > + cc33xx_connection_loss_work); > + wiphy_delayed_work_init(&wlvif->roc_timeout_work, > + cc33xx_roc_timeout_work); > + INIT_LIST_HEAD(&wlvif->list); > + > + return 0; > +} > + > +struct cc33xx_hw_queue_iter_data { > + unsigned long hw_queue_map[BITS_TO_LONGS(CC33XX_NUM_MAC_ADDRESSES)]; > + > + /* current vif */ > + struct ieee80211_vif *vif; > + > + /* is the current vif among those iterated */ > + bool cur_running; > +}; > + > +static void cc33xx_hw_queue_iter(void *data, u8 *mac, struct ieee80211_v= if *vif) > +{ > + struct cc33xx_hw_queue_iter_data *iter_data =3D data; > + > + if (vif->type =3D=3D NL80211_IFTYPE_P2P_DEVICE || > + WARN_ON_ONCE(vif->hw_queue[0] =3D=3D IEEE80211_INVAL_HW_QUEUE)) > + return; > + > + if (iter_data->cur_running || vif =3D=3D iter_data->vif) { > + iter_data->cur_running =3D true; > + return; > + } > + > + __set_bit(vif->hw_queue[0] / NUM_TX_QUEUES, iter_data->hw_queue_map); > +} > + > +static int cc33xx_allocate_hw_queue_base(struct cc33xx *cc, > + struct cc33xx_vif *wlvif) > +{ > + struct ieee80211_vif *vif =3D cc33xx_wlvif_to_vif(wlvif); > + struct cc33xx_hw_queue_iter_data iter_data =3D {}; > + int i, q_base; > + > + if (vif->type =3D=3D NL80211_IFTYPE_P2P_DEVICE) { > + vif->cab_queue =3D IEEE80211_INVAL_HW_QUEUE; > + return 0; > + } > + > + iter_data.vif =3D vif; > + > + /* mark all bits taken by active interfaces */ > + ieee80211_iterate_active_interfaces_mtx(cc->hw, > + IEEE80211_IFACE_ITER_RESUME_ALL, > + cc33xx_hw_queue_iter, &iter_data); > + > + /* the current vif is already running in mac80211 (resume/recovery) */ > + if (iter_data.cur_running) { > + wlvif->hw_queue_base =3D vif->hw_queue[0]; > + cc33xx_debug(cc->dev, DEBUG_MAC80211, > + "using pre-allocated hw queue base %d\n", > + wlvif->hw_queue_base); > + > + /* interface type might have changed type */ > + goto adjust_cab_queue; > + } > + > + q_base =3D find_first_zero_bit(iter_data.hw_queue_map, > + CC33XX_NUM_MAC_ADDRESSES); > + if (q_base >=3D CC33XX_NUM_MAC_ADDRESSES) > + return -EBUSY; > + > + wlvif->hw_queue_base =3D q_base * NUM_TX_QUEUES; > + cc33xx_debug(cc->dev, DEBUG_MAC80211, "allocating hw queue base: %d\n", > + wlvif->hw_queue_base); > + > + for (i =3D 0; i < NUM_TX_QUEUES; i++) { > + cc->queue_stop_reasons[wlvif->hw_queue_base + i] =3D 0; > + /* register hw queues in mac80211 */ > + vif->hw_queue[i] =3D wlvif->hw_queue_base + i; > + } > + > +adjust_cab_queue: > + /* the last places are reserved for cab queues per interface */ > + if (wlvif->bss_type =3D=3D BSS_TYPE_AP_BSS) { > + vif->cab_queue =3D NUM_TX_QUEUES * CC33XX_NUM_MAC_ADDRESSES + > + wlvif->hw_queue_base / NUM_TX_QUEUES; > + } else { > + vif->cab_queue =3D IEEE80211_INVAL_HW_QUEUE; > + } > + > + return 0; > +} > + > +static int cc33xx_op_add_interface(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif) > +{ > + struct cc33xx *cc =3D hw->priv; > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + struct vif_counter_data vif_count; > + int ret =3D 0; > + u8 role_type; > + > + if (cc->plt) { > + dev_err(cc->dev, "Adding Interface not allowed while in PLT mode\n"); > + return -EBUSY; > + } > + > + vif->driver_flags |=3D IEEE80211_VIF_BEACON_FILTER | > + IEEE80211_VIF_SUPPORTS_UAPSD | > + IEEE80211_VIF_SUPPORTS_CQM_RSSI; > + > + cc33xx_get_vif_count(hw, vif, &vif_count); > + > + /* in some very corner case HW recovery scenarios its possible to > + * get here before __cc33xx_op_remove_interface is complete, so > + * opt out if that is the case. > + */ > + if (test_bit(CC33XX_FLAG_RECOVERY_IN_PROGRESS, &cc->flags) || > + test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) > + return -EBUSY; > + > + ret =3D cc33xx_init_vif_data(cc, vif); > + if (ret < 0) > + return ret; > + > + wlvif->cc =3D cc; > + role_type =3D cc33xx_get_role_type(wlvif); > + if (role_type =3D=3D CC33XX_INVALID_ROLE_TYPE) > + return -EINVAL; > + > + ret =3D cc33xx_allocate_hw_queue_base(cc, wlvif); > + if (ret < 0) > + return ret; > + > + if (!cc33xx_is_p2p_mgmt(wlvif)) { > + ret =3D cc33xx_cmd_role_enable(cc, vif->addr, > + role_type, &wlvif->role_id); > + if (ret < 0) > + return ret; > + > + ret =3D cc33xx_init_vif_specific(cc, vif); > + if (ret < 0) > + return ret; > + } else { > + ret =3D cc33xx_cmd_role_enable(cc, vif->addr, CC33XX_ROLE_DEVICE, > + &wlvif->dev_role_id); > + if (ret < 0) > + return ret; > + > + /* needed mainly for configuring rate policies */ > + ret =3D cc33xx_acx_config_ps(cc, wlvif); > + if (ret < 0) > + return ret; > + } > + > + list_add(&wlvif->list, &cc->wlvif_list); > + set_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags); > + > + scoped_guard(mutex, &cc->mutex) { > + if (wlvif->bss_type =3D=3D BSS_TYPE_AP_BSS) > + cc->ap_count++; > + else > + cc->sta_count++; > + } > + > + return ret; > +} > + > +static void __cc33xx_op_remove_interface(struct cc33xx *cc, > + struct ieee80211_vif *vif) > +{ > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + int i; > + bool is_ap =3D (wlvif->bss_type =3D=3D BSS_TYPE_AP_BSS); > + > + if (!test_and_clear_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) > + return; > + > + /* because of hardware recovery, we may get here twice */ > + if (cc->state =3D=3D CC33XX_STATE_OFF) > + return; > + > + if (cc->scan.state !=3D CC33XX_SCAN_STATE_IDLE && > + cc->scan_wlvif =3D=3D wlvif) { > + struct cfg80211_scan_info info =3D { > + .aborted =3D true, > + }; > + > + cc->scan.state =3D CC33XX_SCAN_STATE_IDLE; > + cc->scan_wlvif =3D NULL; > + cc->scan.req =3D NULL; > + ieee80211_scan_completed(cc->hw, &info); > + } > + > + if (cc->sched_vif =3D=3D wlvif) > + cc->sched_vif =3D NULL; > + > + if (cc->roc_vif =3D=3D vif) { > + cc->roc_vif =3D NULL; > + ieee80211_remain_on_channel_expired(cc->hw); > + } > + > + if (!test_bit(CC33XX_FLAG_RECOVERY_IN_PROGRESS, &cc->flags)) { > + /* disable active roles */ > + > + if (wlvif->bss_type =3D=3D BSS_TYPE_STA_BSS) { > + if (wlvif->dev_hlid !=3D CC33XX_INVALID_LINK_ID) > + cc33xx_stop_dev(cc, wlvif); > + } > + > + if (!cc33xx_is_p2p_mgmt(wlvif)) > + cc33xx_cmd_role_disable(cc, &wlvif->role_id); > + else > + cc33xx_cmd_role_disable(cc, &wlvif->dev_role_id); > + } > + > + cc33xx_tx_reset_wlvif(cc, wlvif); > + > + mutex_lock(&cc->mutex); > + /* clear all hlids (except system_hlid) */ > + wlvif->dev_hlid =3D CC33XX_INVALID_LINK_ID; > + > + if (wlvif->bss_type =3D=3D BSS_TYPE_STA_BSS) { > + wlvif->sta.hlid =3D CC33XX_INVALID_LINK_ID; > + cc33xx_free_rate_policy(cc, &wlvif->sta.basic_rate_idx); > + cc33xx_free_rate_policy(cc, &wlvif->sta.ap_rate_idx); > + cc33xx_free_rate_policy(cc, &wlvif->sta.p2p_rate_idx); > + } else { > + wlvif->ap.bcast_hlid =3D CC33XX_INVALID_LINK_ID; > + wlvif->ap.global_hlid =3D CC33XX_INVALID_LINK_ID; > + cc33xx_free_rate_policy(cc, &wlvif->ap.mgmt_rate_idx); > + cc33xx_free_rate_policy(cc, &wlvif->ap.bcast_rate_idx); > + for (i =3D 0; i < CONF_TX_MAX_AC_COUNT; i++) > + cc33xx_free_rate_policy(cc, > + &wlvif->ap.ucast_rate_idx[i]); > + cc33xx_free_ap_keys(wlvif); > + } > + > + dev_kfree_skb(wlvif->probereq); > + wlvif->probereq =3D NULL; > + > + list_del(&wlvif->list); > + memset(wlvif->ap.sta_hlid_map, 0, sizeof(wlvif->ap.sta_hlid_map)); > + wlvif->role_id =3D CC33XX_INVALID_ROLE_ID; > + wlvif->dev_role_id =3D CC33XX_INVALID_ROLE_ID; > + > + if (is_ap) > + cc->ap_count--; > + else > + cc->sta_count--; > + mutex_unlock(&cc->mutex); > + > + /* Last AP, have more stations. Configure sleep auth according to STA. > + * Skip it when on unintended recovery. > + */ > + if (test_bit(CC33XX_FLAG_RECOVERY_IN_PROGRESS, &cc->flags)) > + goto out; > + > + /* mask ap events */ > + if (cc->ap_count =3D=3D 0 && is_ap) > + cc->event_mask &=3D ~cc->ap_event_mask; > + > + if (cc->ap_count =3D=3D 0 && is_ap && cc->sta_count) { > + u8 sta_auth =3D cc->conf.host_conf.conn.sta_sleep_auth; > + /* Configure for power according to debugfs */ > + if (sta_auth !=3D CC33XX_PSM_ILLEGAL) > + cc33xx_acx_sleep_auth(cc, sta_auth); > + /* Configure for ELP power saving */ > + else > + cc33xx_acx_sleep_auth(cc, CC33XX_PSM_ELP); > + } > + > +out: > + wiphy_delayed_work_cancel(cc->hw->wiphy, &wlvif->connection_loss_work); > + wiphy_delayed_work_cancel(cc->hw->wiphy, &wlvif->channel_switch_work); > + wiphy_delayed_work_cancel(cc->hw->wiphy, &wlvif->roc_timeout_work); > +} > + > +static void cc33xx_op_remove_interface(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif) > +{ > + struct cc33xx *cc =3D hw->priv; > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + struct cc33xx_vif *iter; > + struct vif_counter_data vif_count; > + > + cc33xx_get_vif_count(hw, vif, &vif_count); > + > + if (cc->state =3D=3D CC33XX_STATE_OFF || > + !test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) > + return; > + > + /* cc->vif can be null here if someone shuts down the interface > + * just when hardware recovery has been started. > + */ > + cc33xx_for_each_wlvif(cc, iter) { > + if (iter !=3D wlvif) > + continue; > + > + __cc33xx_op_remove_interface(cc, vif); > + break; > + } > + WARN_ON(iter !=3D wlvif); > +} > + > +static int cc33xx_op_change_interface(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif, > + enum nl80211_iftype new_type, bool p2p) > +{ > + struct cc33xx *cc =3D hw->priv; > + int ret; > + > + set_bit(CC33XX_FLAG_VIF_CHANGE_IN_PROGRESS, &cc->flags); > + cc33xx_op_remove_interface(hw, vif); > + > + vif->type =3D new_type; > + vif->p2p =3D p2p; > + ret =3D cc33xx_op_add_interface(hw, vif); > + > + clear_bit(CC33XX_FLAG_VIF_CHANGE_IN_PROGRESS, &cc->flags); > + return ret; > +} > + > +static int cc33xx_join(struct cc33xx *cc, struct cc33xx_vif *wlvif) > +{ > + /* One of the side effects of the JOIN command is that is clears > + * WPA/WPA2 keys from the chipset. Performing a JOIN while associated > + * to a WPA/WPA2 access point will therefore kill the data-path. > + * Currently the only valid scenario for JOIN during association > + * is on roaming, in which case we will also be given new keys. > + * Keep the below message for now, unless it starts bothering > + * users who really like to roam a lot :) > + */ > + if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) > + dev_info(cc->dev, "JOIN while associated.\n"); > + > + /* clear encryption type */ > + wlvif->encryption_type =3D KEY_NONE; > + > + return cc33xx_cmd_role_start_sta(cc, wlvif); > +} > + > +static int cc33xx_ssid_set(struct cc33xx_vif *wlvif, > + struct sk_buff *skb, int offset) > +{ > + u8 ssid_len; > + const u8 *ptr =3D cfg80211_find_ie(WLAN_EID_SSID, skb->data + offset, > + skb->len - offset); > + > + if (!ptr) { > + dev_err(wlvif->cc->dev, "No SSID in IEs!\n"); > + return -ENOENT; > + } > + > + ssid_len =3D ptr[1]; > + if (ssid_len > IEEE80211_MAX_SSID_LEN) { > + dev_err(wlvif->cc->dev, "SSID is too long!\n"); > + return -EINVAL; > + } > + > + wlvif->ssid_len =3D ssid_len; > + memcpy(wlvif->ssid, ptr + 2, ssid_len); > + return 0; > +} > + > +static int cc33xx_set_ssid(struct cc33xx *cc, struct cc33xx_vif *wlvif) > +{ > + struct ieee80211_vif *vif =3D cc33xx_wlvif_to_vif(wlvif); > + struct sk_buff *skb; > + int ieoffset; > + > + /* we currently only support setting the ssid from the ap probe req */ > + if (wlvif->bss_type !=3D BSS_TYPE_STA_BSS) > + return -EINVAL; > + > + skb =3D ieee80211_ap_probereq_get(cc->hw, vif); > + if (!skb) > + return -EINVAL; > + > + ieoffset =3D offsetof(struct ieee80211_mgmt, u.probe_req.variable); > + cc33xx_ssid_set(wlvif, skb, ieoffset); > + dev_kfree_skb(skb); > + > + return 0; > +} > + > +static int cc33xx_set_assoc(struct cc33xx *cc, struct cc33xx_vif *wlvif, > + struct ieee80211_bss_conf *bss_conf, > + struct ieee80211_sta *sta, > + struct ieee80211_vif *vif, u32 sta_rate_set) > +{ > + int ret; > + > + wlvif->aid =3D vif->cfg.aid; > + wlvif->channel_type =3D cfg80211_get_chandef_type(&bss_conf->chanreq.op= er); > + wlvif->beacon_int =3D bss_conf->beacon_int; > + wlvif->wmm_enabled =3D bss_conf->qos; > + > + wlvif->nontransmitted =3D bss_conf->nontransmitted; > + cc33xx_debug(cc->dev, DEBUG_MAC80211, "set_assoc mbssid params: nonTxbs= sid: %d, idx: %d, max_ind: %d, trans_bssid: %pM, ema_ap: %d\n", > + bss_conf->nontransmitted, bss_conf->bssid_index, > + bss_conf->bssid_indicator, bss_conf->transmitter_bssid, > + bss_conf->ema_ap); > + wlvif->bssid_index =3D bss_conf->bssid_index; > + wlvif->bssid_indicator =3D bss_conf->bssid_indicator; > + memcpy(wlvif->transmitter_bssid, bss_conf->transmitter_bssid, ETH_ALEN); > + > + set_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags); > + > + ret =3D cc33xx_assoc_info_cfg(cc, wlvif, sta, wlvif->aid); > + if (ret < 0) > + return ret; > + > + if (sta_rate_set) > + wlvif->rate_set =3D cc33xx_tx_enabled_rates_get(cc, sta_rate_set, > + wlvif->band); > + > + return ret; > +} > + > +static int cc33xx_unset_assoc(struct cc33xx *cc, struct cc33xx_vif *wlvi= f) > +{ > + int ret; > + bool sta =3D wlvif->bss_type =3D=3D BSS_TYPE_STA_BSS; > + > + /* make sure we are connected (sta) joined */ > + if (sta && !test_and_clear_bit(WLVIF_FLAG_STA_ASSOCIATED, > + &wlvif->flags)) > + return 0; > + > + if (sta) { > + /* use defaults when not associated */ > + wlvif->aid =3D 0; > + > + /* free probe-request template */ > + dev_kfree_skb(wlvif->probereq); > + wlvif->probereq =3D NULL; > + > + /* disable beacon filtering */ > + ret =3D cc33xx_acx_beacon_filter_opt(cc, wlvif, false); > + if (ret < 0) > + return ret; > + } > + > + if (test_and_clear_bit(WLVIF_FLAG_CS_PROGRESS, &wlvif->flags)) { > + struct ieee80211_vif *vif =3D cc33xx_wlvif_to_vif(wlvif); > + > + cc33xx_cmd_stop_channel_switch(cc, wlvif); > + ieee80211_chswitch_done(vif, false, 0); > + wiphy_delayed_work_cancel(cc->hw->wiphy, > + &wlvif->channel_switch_work); > + } > + > + return 0; > +} > + > +static void cc33xx_set_band_rate(struct cc33xx_vif *wlvif) > +{ > + wlvif->basic_rate_set =3D wlvif->bitrate_masks[wlvif->band]; > + wlvif->rate_set =3D wlvif->basic_rate_set; > +} > + > +static void cc33xx_sta_handle_idle(struct cc33xx *cc, > + struct cc33xx_vif *wlvif, bool idle) > +{ > + bool cur_idle =3D !test_bit(WLVIF_FLAG_ACTIVE, &wlvif->flags); > + > + if (idle =3D=3D cur_idle) > + return; > + > + if (idle) { > + clear_bit(WLVIF_FLAG_ACTIVE, &wlvif->flags); > + } else { > + /* The current firmware only supports sched_scan in idle */ > + if (cc->sched_vif =3D=3D wlvif) > + cc33xx_scan_sched_scan_stop(cc, wlvif); > + > + set_bit(WLVIF_FLAG_ACTIVE, &wlvif->flags); > + } > +} > + > +struct cc33xx_filter_params { > + bool enabled; > + int mc_list_length; > + u8 mc_list[ACX_MC_ADDRESS_GROUP_MAX][ETH_ALEN]; > +}; > + > +static u64 cc33xx_op_prepare_multicast(struct ieee80211_hw *hw, > + struct netdev_hw_addr_list *mc_list) > +{ > + struct cc33xx_filter_params *fp; > + struct netdev_hw_addr *ha; > + struct cc33xx *cc =3D hw->priv; > + > + fp =3D kzalloc_obj(*fp); > + if (!fp) { > + dev_err(cc->dev, "Out of memory setting filters.\n"); > + return 0; > + } > + > + /* update multicast filtering parameters */ > + fp->mc_list_length =3D 0; > + if (netdev_hw_addr_list_count(mc_list) > ACX_MC_ADDRESS_GROUP_MAX) { > + fp->enabled =3D false; > + } else { > + fp->enabled =3D true; > + netdev_hw_addr_list_for_each(ha, mc_list) { > + memcpy(fp->mc_list[fp->mc_list_length], > + ha->addr, ETH_ALEN); > + fp->mc_list_length++; > + } > + } > + > + return (u64)(unsigned long)fp; > +} > + > +#define CC33XX_SUPPORTED_FILTERS (FIF_ALLMULTI) > + > +static void cc33xx_op_configure_filter(struct ieee80211_hw *hw, > + unsigned int changed, > + unsigned int *total, u64 multicast) > +{ > + struct cc33xx_filter_params *fp =3D (void *)(unsigned long)multicast; > + struct cc33xx *cc =3D hw->priv; > + > + *total &=3D CC33XX_SUPPORTED_FILTERS; > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) > + goto out; > + > + if (!fp || !fp->enabled || *total & FIF_ALLMULTI) > + cc33xx_acx_group_address_tbl(cc, false, NULL, 0); > + else > + cc33xx_acx_group_address_tbl(cc, true, fp->mc_list, fp->mc_list_length= ); > + > +out: > + kfree(fp); > +} > + > +static int cc33xx_record_ap_key(struct cc33xx_vif *wlvif, > + u8 id, u8 key_type, u8 key_size, const u8 *key, > + u8 hlid, u32 tx_seq_32, u16 tx_seq_16) > +{ > + struct cc33xx_ap_key *ap_key; > + int i; > + > + if (key_size > MAX_KEY_SIZE) > + return -EINVAL; > + > + /* Find next free entry in ap_keys. Also check we are not replacing > + * an existing key. > + */ > + for (i =3D 0; i < MAX_NUM_KEYS; i++) { > + if (!wlvif->ap.recorded_keys[i]) > + break; > + > + if (wlvif->ap.recorded_keys[i]->id =3D=3D id) { > + dev_warn(wlvif->cc->dev, "trying to record key replacement\n"); > + return -EINVAL; > + } > + } > + > + if (i =3D=3D MAX_NUM_KEYS) > + return -EBUSY; > + > + ap_key =3D kzalloc_obj(*ap_key); > + if (!ap_key) > + return -ENOMEM; > + > + ap_key->id =3D id; > + ap_key->key_type =3D key_type; > + ap_key->key_size =3D key_size; > + memcpy(ap_key->key, key, key_size); > + ap_key->hlid =3D hlid; > + ap_key->tx_seq_32 =3D tx_seq_32; > + ap_key->tx_seq_16 =3D tx_seq_16; > + > + wlvif->ap.recorded_keys[i] =3D ap_key; > + return 0; > +} > + > +static void cc33xx_free_ap_keys(struct cc33xx_vif *wlvif) > +{ > + int i; > + > + for (i =3D 0; i < MAX_NUM_KEYS; i++) { > + kfree(wlvif->ap.recorded_keys[i]); > + wlvif->ap.recorded_keys[i] =3D NULL; > + } > +} > + > +static int cc33xx_ap_init_hwenc(struct cc33xx *cc, struct cc33xx_vif *wl= vif) > +{ > + int i, ret =3D 0; > + struct cc33xx_ap_key *key; > + bool wep_key_added =3D false; > + > + for (i =3D 0; i < MAX_NUM_KEYS; i++) { > + u8 hlid; > + > + if (!wlvif->ap.recorded_keys[i]) > + break; > + > + key =3D wlvif->ap.recorded_keys[i]; > + hlid =3D key->hlid; > + if (hlid =3D=3D CC33XX_INVALID_LINK_ID) > + hlid =3D wlvif->ap.bcast_hlid; > + > + ret =3D cc33xx_cmd_set_ap_key(cc, wlvif, KEY_ADD_OR_REPLACE, > + key->id, key->key_type, > + key->key_size, key->key, hlid, > + key->tx_seq_32, key->tx_seq_16); > + if (ret < 0) > + goto out; > + > + if (key->key_type =3D=3D KEY_WEP) > + wep_key_added =3D true; > + } > + > + if (wep_key_added) { > + ret =3D cc33xx_cmd_set_default_wep_key(cc, wlvif->default_key, > + wlvif->ap.bcast_hlid); > + if (ret < 0) > + goto out; > + } > + > +out: > + cc33xx_free_ap_keys(wlvif); > + return ret; > +} > + > +static int cc33xx_config_key(struct cc33xx *cc, struct cc33xx_vif *wlvif, > + u16 action, u8 id, u8 key_type, u8 key_size, > + const u8 *key, u32 tx_seq_32, u16 tx_seq_16, > + struct ieee80211_sta *sta) > +{ > + int ret; > + bool is_ap =3D (wlvif->bss_type =3D=3D BSS_TYPE_AP_BSS); > + > + if (is_ap) { > + struct cc33xx_station *wl_sta; > + u8 hlid; > + > + if (sta) { > + wl_sta =3D (struct cc33xx_station *)sta->drv_priv; > + hlid =3D wl_sta->hlid; > + } else { > + hlid =3D wlvif->ap.bcast_hlid; > + } > + > + if (!test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) { > + /* We do not support removing keys after AP shutdown. > + * Pretend we do to make mac80211 happy. > + */ > + if (action !=3D KEY_ADD_OR_REPLACE) > + return 0; > + > + ret =3D cc33xx_record_ap_key(wlvif, id, key_type, > + key_size, key, hlid, > + tx_seq_32, tx_seq_16); > + } else { > + ret =3D cc33xx_cmd_set_ap_key(cc, wlvif, action, id, > + key_type, key_size, key, > + hlid, tx_seq_32, tx_seq_16); > + } > + > + if (ret < 0) > + return ret; > + } else { > + const u8 *addr =3D sta ? sta->addr : bcast_addr; > + > + if (is_zero_ether_addr(addr)) { > + /* We dont support TX only encryption */ > + return -EOPNOTSUPP; > + } > + > + /* The cc33xx does not allow to remove unicast keys - they > + * will be cleared automatically on next CMD_JOIN. Ignore the > + * request silently, as we dont want the mac80211 to emit > + * an error message. > + */ > + if (action =3D=3D KEY_REMOVE && !is_broadcast_ether_addr(addr)) > + return 0; > + > + /* don't remove key if hlid was already deleted */ > + if (action =3D=3D KEY_REMOVE && > + wlvif->sta.hlid =3D=3D CC33XX_INVALID_LINK_ID) > + return 0; > + > + ret =3D cc33xx_cmd_set_sta_key(cc, wlvif, action, id, key_type, > + key_size, key, addr, tx_seq_32, > + tx_seq_16); > + if (ret < 0) > + return ret; > + } > + > + return 0; > +} > + > +static int cc33xx_set_key(struct cc33xx *cc, enum set_key_cmd cmd, > + struct ieee80211_vif *vif, struct ieee80211_sta *sta, > + struct ieee80211_key_conf *key_conf) > +{ > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + int ret; > + u32 tx_seq_32 =3D 0; > + u16 tx_seq_16 =3D 0; > + u8 key_type; > + u8 hlid; > + > + if (wlvif->bss_type =3D=3D BSS_TYPE_AP_BSS) { > + if (sta) { > + struct cc33xx_station *wl_sta =3D (void *)sta->drv_priv; > + > + hlid =3D wl_sta->hlid; > + } else { > + hlid =3D wlvif->ap.bcast_hlid; > + } > + } else { > + hlid =3D wlvif->sta.hlid; > + } > + > + if (hlid !=3D CC33XX_INVALID_LINK_ID) { > + u64 tx_seq =3D cc->links[hlid].total_freed_pkts; > + > + tx_seq_32 =3D CC33XX_TX_SECURITY_HI32(tx_seq); > + tx_seq_16 =3D CC33XX_TX_SECURITY_LO16(tx_seq); > + } > + > + switch (key_conf->cipher) { > + case WLAN_CIPHER_SUITE_WEP40: > + case WLAN_CIPHER_SUITE_WEP104: > + key_type =3D KEY_WEP; > + key_conf->hw_key_idx =3D key_conf->keyidx; > + break; > + case WLAN_CIPHER_SUITE_TKIP: > + key_type =3D KEY_TKIP; > + key_conf->hw_key_idx =3D key_conf->keyidx; > + break; > + case WLAN_CIPHER_SUITE_CCMP: > + key_type =3D KEY_AES; > + key_conf->flags |=3D IEEE80211_KEY_FLAG_PUT_IV_SPACE; > + break; > + case WLAN_CIPHER_SUITE_GCMP: > + key_type =3D KEY_GCMP128; > + key_conf->flags |=3D IEEE80211_KEY_FLAG_PUT_IV_SPACE; > + break; > + case WLAN_CIPHER_SUITE_CCMP_256: > + key_type =3D KEY_CCMP256; > + key_conf->flags |=3D IEEE80211_KEY_FLAG_PUT_IV_SPACE; > + break; > + case WLAN_CIPHER_SUITE_GCMP_256: > + key_type =3D KEY_GCMP_256; > + key_conf->flags |=3D IEEE80211_KEY_FLAG_PUT_IV_SPACE; > + break; > + case WLAN_CIPHER_SUITE_AES_CMAC: > + key_type =3D KEY_IGTK; > + break; > + case WLAN_CIPHER_SUITE_BIP_CMAC_256: > + key_type =3D KEY_CMAC_256; > + break; > + case WLAN_CIPHER_SUITE_BIP_GMAC_128: > + key_type =3D KEY_GMAC_128; > + break; > + case WLAN_CIPHER_SUITE_BIP_GMAC_256: > + key_type =3D KEY_GMAC_256; > + break; > + default: > + dev_err(cc->dev, "Unknown key algo 0x%x\n", key_conf->cipher); > + > + return -EOPNOTSUPP; > + } > + > + switch (cmd) { > + case SET_KEY: > + ret =3D cc33xx_config_key(cc, wlvif, KEY_ADD_OR_REPLACE, > + key_conf->keyidx, key_type, key_conf->keylen, > + key_conf->key, tx_seq_32, tx_seq_16, sta); > + if (ret < 0) { > + dev_err(cc->dev, "Could not add or replace key\n"); > + return ret; > + } > + > + if (wlvif->bss_type =3D=3D BSS_TYPE_STA_BSS && > + (sta || key_type =3D=3D KEY_WEP)) > + wlvif->encryption_type =3D key_type; > + break; > + > + case DISABLE_KEY: > + ret =3D cc33xx_config_key(cc, wlvif, KEY_REMOVE, key_conf->keyidx, > + key_type, key_conf->keylen, > + key_conf->key, 0, 0, sta); > + if (ret < 0) { > + dev_err(cc->dev, "Could not remove key\n"); > + return ret; > + } > + break; > + > + default: > + dev_err(cc->dev, "Unsupported key cmd 0x%x\n", cmd); > + return -EOPNOTSUPP; > + } > + > + return ret; > +} > + > +static int cc33xx_hw_set_key(struct cc33xx *cc, enum set_key_cmd cmd, > + struct ieee80211_vif *vif, struct ieee80211_sta *sta, > + struct ieee80211_key_conf *key_conf) > +{ > + bool special_enc; > + int ret; > + > + special_enc =3D (key_conf->cipher =3D=3D WLAN_CIPHER_SUITE_TKIP); > + > + guard(mutex)(&cc->mutex); > + > + ret =3D cc33xx_set_key(cc, cmd, vif, sta, key_conf); > + if (ret < 0) > + return ret; > + > + /* when adding the first or removing the last TKIP key, > + * we have to adjust the number of spare blocks. > + */ > + if (special_enc) { > + if (cmd =3D=3D SET_KEY) { > + /* first key */ > + cc->extra_spare_key_count++; > + } else if (cmd =3D=3D DISABLE_KEY) { > + /* last key */ > + cc->extra_spare_key_count--; > + } > + } > + > + return ret; > +} > + > +static int cc33xx_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd c= md, > + struct ieee80211_vif *vif, > + struct ieee80211_sta *sta, > + struct ieee80211_key_conf *key_conf) > +{ > + struct cc33xx *cc =3D hw->priv; > + int ret; > + bool might_change_spare =3D (key_conf->cipher =3D=3D WLAN_CIPHER_SUITE_= TKIP); > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) > + return 0; > + > + if (might_change_spare) { > + /* stop the queues and flush to ensure the next packets are > + * in sync with FW spare block accounting > + */ > + cc33xx_stop_queues(cc, CC33XX_QUEUE_STOP_REASON_SPARE_BLK); > + cc33xx_tx_flush(cc); > + } > + > + ret =3D cc33xx_hw_set_key(cc, cmd, vif, sta, key_conf); > + > + if (might_change_spare) > + cc33xx_wake_queues(cc, CC33XX_QUEUE_STOP_REASON_SPARE_BLK); > + > + return ret; > +} > + > +static void cc33xx_op_set_default_key_idx(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif, > + int key_idx) > +{ > + struct cc33xx *cc =3D hw->priv; > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + > + cc33xx_debug(cc->dev, DEBUG_MAC80211, > + "mac80211 set default key idx %d\n", key_idx); > + > + /* we don't handle unsetting of default key */ > + if (key_idx =3D=3D -1) > + return; > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) > + return; > + > + guard(mutex)(&cc->mutex); > + > + wlvif->default_key =3D key_idx; > + > + /* the default WEP key needs to be configured at least once */ > + if (wlvif->encryption_type =3D=3D KEY_WEP) > + cc33xx_cmd_set_default_wep_key(cc, key_idx, wlvif->sta.hlid); > +} > + > +static int cc33xx_op_hw_scan(struct ieee80211_hw *hw, struct ieee80211_v= if *vif, > + struct ieee80211_scan_request *hw_req) > +{ > + struct cfg80211_scan_request *req =3D &hw_req->req; > + struct cc33xx *cc =3D hw->priv; > + int ret; > + u8 *ssid =3D NULL; > + size_t len =3D 0; > + > + if (req->n_ssids) { > + ssid =3D req->ssids[0].ssid; > + len =3D req->ssids[0].ssid_len; > + } > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) { > + /* We cannot return -EBUSY here because cfg80211 will expect > + * a call to ieee80211_scan_completed if we do - in this case > + * there won't be any call. > + */ > + return -EAGAIN; > + } > + > + /* fail if there is any role in ROC */ > + if (find_first_bit(cc->roc_map, CC33XX_MAX_ROLES) < CC33XX_MAX_ROLES) { > + /* don't allow scanning right now */ > + return -EBUSY; > + } > + > + ret =3D cc33xx_scan(hw->priv, vif, ssid, len, req); > + > + return ret; > +} > + > +static void cc33xx_op_cancel_hw_scan(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif) > +{ > + struct cc33xx *cc =3D hw->priv; > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + struct cfg80211_scan_info info =3D { > + .aborted =3D true, > + }; > + int ret; > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) > + return; > + > + if (cc->scan.state =3D=3D CC33XX_SCAN_STATE_IDLE) > + return; > + > + if (cc->scan.state !=3D CC33XX_SCAN_STATE_DONE) { > + ret =3D cc33xx_scan_stop(cc, wlvif); > + if (ret < 0) > + return; > + } > + > + cc->scan.state =3D CC33XX_SCAN_STATE_IDLE; > + cc->scan_wlvif =3D NULL; > + cc->scan.req =3D NULL; > + ieee80211_scan_completed(cc->hw, &info); > + > + wiphy_delayed_work_cancel(cc->hw->wiphy, &cc->scan_complete_work); > +} > + > +static int cc33xx_op_sched_scan_start(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif, > + struct cfg80211_sched_scan_request *req, > + struct ieee80211_scan_ies *ies) > +{ > + struct cc33xx *cc =3D hw->priv; > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + int ret; > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) > + return -EAGAIN; > + > + ret =3D cc33xx_sched_scan_start(cc, wlvif, req, ies); > + if (!ret) > + cc->sched_vif =3D wlvif; > + > + return ret; > +} > + > +static int cc33xx_op_sched_scan_stop(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif) > +{ > + struct cc33xx *cc =3D hw->priv; > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) > + return 0; > + > + cc->sched_vif =3D NULL; > + > + cc33xx_scan_sched_scan_stop(cc, wlvif); > + > + return 0; > +} > + > +static int cc33xx_op_set_frag_threshold(struct ieee80211_hw *hw, int rad= io_idx, > + u32 value) > +{ > + return 0; > +} > + > +static int cc33xx_op_set_rts_threshold(struct ieee80211_hw *hw, int radi= o_idx, > + u32 value) > +{ > + return 0; > +} > + > +static int cc33xx_bss_erp_info_changed(struct cc33xx *cc, > + struct ieee80211_vif *vif, > + struct ieee80211_bss_conf *bss_conf, > + u64 changed) > +{ > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + int ret =3D 0; > + > + if (changed & BSS_CHANGED_ERP_SLOT) { > + if (bss_conf->use_short_slot) > + ret =3D cc33xx_acx_slot(cc, wlvif, SLOT_TIME_SHORT); > + else > + ret =3D cc33xx_acx_slot(cc, wlvif, SLOT_TIME_LONG); > + if (ret < 0) { > + dev_warn(cc->dev, "Set slot time failed %d\n", ret); > + return ret; > + } > + } > + > + if (changed & BSS_CHANGED_ERP_PREAMBLE) { > + if (bss_conf->use_short_preamble) > + cc33xx_acx_set_preamble(cc, wlvif, ACX_PREAMBLE_SHORT); > + else > + cc33xx_acx_set_preamble(cc, wlvif, ACX_PREAMBLE_LONG); > + } > + > + if (changed & BSS_CHANGED_ERP_CTS_PROT) { > + if (bss_conf->use_cts_prot) { > + ret =3D cc33xx_acx_cts_protect(cc, wlvif, > + CTSPROTECT_ENABLE); > + } else { > + ret =3D cc33xx_acx_cts_protect(cc, wlvif, > + CTSPROTECT_DISABLE); > + } > + > + if (ret < 0) { > + dev_warn(cc->dev, "Set ctsprotect failed %d\n", ret); > + return ret; > + } > + } > + > + return ret; > +} > + > +static int cc33xx_set_beacon_template(struct cc33xx *cc, > + struct ieee80211_vif *vif) > +{ > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + int ret; > + int ieoffset =3D offsetof(struct ieee80211_mgmt, u.beacon.variable); > + struct sk_buff *beacon =3D ieee80211_beacon_get(cc->hw, vif, 0); > + > + struct cc33xx_cmd_set_beacon_info *cmd __free(kfree) =3D NULL; > + > + if (!beacon) > + return -EINVAL; > + > + ret =3D cc33xx_ssid_set(wlvif, beacon, ieoffset); > + if (ret < 0) > + goto end_bcn; > + > + cmd =3D kzalloc_obj(*cmd); > + if (!cmd) { > + ret =3D -ENOMEM; > + goto end_bcn; > + } > + > + cmd->role_id =3D wlvif->role_id; > + cmd->beacon_len =3D cpu_to_le16(beacon->len); > + > + memcpy(cmd->beacon, beacon->data, beacon->len); > + > + ret =3D cc33xx_cmd_send(cc, CMD_AP_SET_BEACON_INFO, cmd, sizeof(*cmd), = 0); > + > +end_bcn: > + dev_kfree_skb(beacon); > + return ret; > +} > + > +static int cc33xx_bss_beacon_info_changed(struct cc33xx *cc, > + struct ieee80211_vif *vif, > + struct ieee80211_bss_conf *bss_conf, > + u32 changed) > +{ > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + int ret; > + > + if (changed & BSS_CHANGED_BEACON_INT) { > + cc33xx_debug(cc->dev, DEBUG_MASTER, "beacon interval updated: %d\n", > + bss_conf->beacon_int); > + > + wlvif->beacon_int =3D bss_conf->beacon_int; > + } > + > + if (changed & BSS_CHANGED_BEACON) { > + ret =3D cc33xx_set_beacon_template(cc, vif); > + if (ret < 0) { > + dev_err(cc->dev, "set beacon template failed: %d\n", ret); > + return ret; > + } > + } > + > + return 0; > +} > + > +/* AP mode changes */ > +static void cc33xx_bss_info_changed_ap(struct cc33xx *cc, > + struct ieee80211_vif *vif, > + struct ieee80211_bss_conf *bss_conf, > + u64 changed) > +{ > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + int ret =3D 0; > + > + if (changed & BSS_CHANGED_BASIC_RATES) { > + u32 rates =3D bss_conf->basic_rates; > + u32 supported_rates =3D 0; > + > + wlvif->basic_rate_set =3D cc33xx_tx_enabled_rates_get(cc, rates, > + wlvif->band); > + wlvif->basic_rate =3D cc33xx_tx_min_rate_get(wlvif->basic_rate_set); > + > + supported_rates =3D CONF_TX_ENABLED_RATES | CONF_TX_MCS_RATES; > + ret =3D cc33xx_update_ap_rates(cc, wlvif->role_id, > + wlvif->basic_rate_set, > + supported_rates); > + > + ret =3D cc33xx_set_beacon_template(cc, vif); > + if (ret < 0) > + return; > + } > + > + ret =3D cc33xx_bss_beacon_info_changed(cc, vif, bss_conf, changed); > + if (ret < 0) > + return; > + > + if (changed & BSS_CHANGED_BEACON_ENABLED) { > + if (bss_conf->enable_beacon) { > + if (!test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) { > + ret =3D cc33xx_cmd_role_start_ap(cc, wlvif); > + if (ret < 0) > + return; > + > + ret =3D cc33xx_ap_init_hwenc(cc, wlvif); > + if (ret < 0) > + return; > + > + set_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags); > + } > + } else { > + if (test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) { > + /* AP might be in ROC in case we have just > + * sent auth reply. handle it. > + */ > + if (test_bit(wlvif->role_id, cc->roc_map)) > + cc33xx_croc(cc, wlvif->role_id); > + > + ret =3D cc33xx_cmd_role_stop_ap(cc, wlvif); > + if (ret < 0) > + return; > + > + clear_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags); > + clear_bit(WLVIF_FLAG_AP_PROBE_RESP_SET, > + &wlvif->flags); > + } > + } > + } > + > + cc33xx_bss_erp_info_changed(cc, vif, bss_conf, changed); > +} > + > +static int cc33xx_set_bssid(struct cc33xx *cc, struct cc33xx_vif *wlvif, > + struct ieee80211_bss_conf *bss_conf, > + struct ieee80211_vif *vif, > + u32 sta_rate_set) > +{ > + u32 rates; > + > + cc33xx_debug(cc->dev, DEBUG_MAC80211, "changed_bssid: %pM, aid: %d, bcn= _int: %d, brates: 0x%x sta_rate_set: 0x%x, nontx: %d\n", > + bss_conf->bssid, vif->cfg.aid, bss_conf->beacon_int, > + bss_conf->basic_rates, sta_rate_set, > + bss_conf->nontransmitted); > + > + wlvif->beacon_int =3D bss_conf->beacon_int; > + rates =3D bss_conf->basic_rates; > + wlvif->basic_rate_set =3D cc33xx_tx_enabled_rates_get(cc, rates, > + wlvif->band); > + wlvif->basic_rate =3D cc33xx_tx_min_rate_get(wlvif->basic_rate_set); > + > + if (sta_rate_set) > + wlvif->rate_set =3D cc33xx_tx_enabled_rates_get(cc, sta_rate_set, > + wlvif->band); > + > + wlvif->nontransmitted =3D bss_conf->nontransmitted; > + cc33xx_debug(cc->dev, DEBUG_MAC80211, "changed_mbssid: nonTxbssid: %d, = idx: %d, max_ind: %d, trans_bssid: %pM, ema_ap: %d\n", > + bss_conf->nontransmitted, bss_conf->bssid_index, > + bss_conf->bssid_indicator, bss_conf->transmitter_bssid, > + bss_conf->ema_ap); > + > + if (bss_conf->nontransmitted) { > + wlvif->bssid_index =3D bss_conf->bssid_index; > + wlvif->bssid_indicator =3D bss_conf->bssid_indicator; > + memcpy(wlvif->transmitter_bssid, > + bss_conf->transmitter_bssid, > + ETH_ALEN); > + } > + > + /* we only support sched_scan while not connected */ > + if (cc->sched_vif =3D=3D wlvif) > + cc33xx_scan_sched_scan_stop(cc, wlvif); > + > + cc33xx_set_ssid(cc, wlvif); > + > + set_bit(WLVIF_FLAG_IN_USE, &wlvif->flags); > + > + return 0; > +} > + > +static int cc33xx_clear_bssid(struct cc33xx *cc, struct cc33xx_vif *wlvi= f) > +{ > + int ret; > + > + /* revert back to minimum rates for the current band */ > + cc33xx_set_band_rate(wlvif); > + wlvif->basic_rate =3D cc33xx_tx_min_rate_get(wlvif->basic_rate_set); > + > + if (wlvif->bss_type =3D=3D BSS_TYPE_STA_BSS && > + test_bit(WLVIF_FLAG_IN_USE, &wlvif->flags)) { > + ret =3D cc33xx_cmd_role_stop_sta(cc, wlvif); > + if (ret < 0) > + return ret; > + } > + > + clear_bit(WLVIF_FLAG_IN_USE, &wlvif->flags); > + return 0; > +} > + > +static void cc33xx_sta_set_he(struct cc33xx *cc, struct cc33xx_vif *wlvi= f, bool has_he) > +{ > + struct cc33xx_vif *wlvif_itr; > + u8 he_count =3D 0; > + > + wlvif->sta_has_he =3D has_he; > + > + dev_info(cc->dev, "HE %s\n", str_enabled_disabled(has_he)); > + > + cc33xx_for_each_wlvif_sta(cc, wlvif_itr) { > + /* check for all valid link id's */ > + if (wlvif_itr->role_id !=3D 0xFF && wlvif_itr->sta_has_he) > + he_count++; > + } > + > + /* There can't be two stations connected with HE supported links */ > + if (he_count > 1) > + dev_err(cc->dev, "Both station interfaces has HE enabled!\n"); > +} > + > +/* STA/IBSS mode changes */ > +static void cc33xx_bss_info_changed_sta(struct cc33xx *cc, > + struct ieee80211_vif *vif, > + struct ieee80211_bss_conf *bss_conf, > + u64 changed) > +{ > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + bool do_join =3D false; > + u32 sta_rate_set =3D 0; > + int ret; > + struct ieee80211_sta *sta =3D NULL; > + bool sta_exists =3D false; > + struct ieee80211_sta_ht_cap sta_ht_cap; > + struct ieee80211_sta_he_cap sta_he_cap; > + > + if (changed & BSS_CHANGED_IDLE) > + cc33xx_sta_handle_idle(cc, wlvif, vif->cfg.idle); > + > + if (changed & BSS_CHANGED_CQM) > + wlvif->rssi_thold =3D bss_conf->cqm_rssi_thold; > + > + if (changed & (BSS_CHANGED_BSSID | BSS_CHANGED_HT | BSS_CHANGED_ASSOC))= { > + rcu_read_lock(); > + sta =3D ieee80211_find_sta(vif, bss_conf->bssid); > + if (sta) { > + u8 *rx_mask =3D sta->deflink.ht_cap.mcs.rx_mask; > + > + /* save the supp_rates of the ap */ > + sta_rate_set =3D sta->deflink.supp_rates[wlvif->band]; > + if (sta->deflink.ht_cap.ht_supported) { > + sta_rate_set |=3D > + (rx_mask[0] << HW_HT_RATES_OFFSET) | > + (rx_mask[1] << HW_MIMO_RATES_OFFSET); > + } > + sta_ht_cap =3D sta->deflink.ht_cap; > + sta_he_cap =3D sta->deflink.he_cap; > + sta_exists =3D true; > + } > + > + rcu_read_unlock(); > + } > + > + if (changed & BSS_CHANGED_BSSID) { > + if (!is_zero_ether_addr(bss_conf->bssid)) { > + ret =3D cc33xx_set_bssid(cc, wlvif, > + bss_conf, vif, sta_rate_set); > + if (ret < 0) > + return; > + > + /* Need to update the BSSID (for filtering etc) */ > + do_join =3D true; > + } else { > + ret =3D cc33xx_clear_bssid(cc, wlvif); > + if (ret < 0) > + return; > + } > + } > + > + if ((changed & BSS_CHANGED_BEACON_INFO) && bss_conf->dtim_period) { > + /* enable beacon filtering */ > + ret =3D cc33xx_acx_beacon_filter_opt(cc, wlvif, true); > + if (ret < 0) > + return; > + } > + > + ret =3D cc33xx_bss_erp_info_changed(cc, vif, bss_conf, changed); > + if (ret < 0) > + return; > + > + if (do_join) { > + ret =3D cc33xx_join(cc, wlvif); > + if (ret < 0) { > + dev_warn(cc->dev, "cmd join failed %d\n", ret); > + return; > + } > + } > + > + if (changed & BSS_CHANGED_ASSOC) { > + if (vif->cfg.assoc) { > + ret =3D cc33xx_set_assoc(cc, wlvif, bss_conf, sta, vif, > + sta_rate_set); > + if (ret < 0) > + return; > + > + if (test_bit(WLVIF_FLAG_STA_AUTHORIZED, &wlvif->flags)) > + cc33xx_set_authorized(cc, wlvif); > + > + if (sta) > + cc33xx_sta_set_he(cc, wlvif, sta->deflink.he_cap.has_he); > + > + } else { > + cc33xx_unset_assoc(cc, wlvif); > + } > + } > + > + if (changed & BSS_CHANGED_PS) { > + if (vif->cfg.ps && > + test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) && > + !test_bit(WLVIF_FLAG_IN_PS, &wlvif->flags)) { > + int ps_mode; > + char *ps_mode_str; > + > + if (cc->conf.host_conf.conn.forced_ps) { > + ps_mode =3D STATION_POWER_SAVE_MODE; > + ps_mode_str =3D "forced"; > + } else { > + ps_mode =3D STATION_AUTO_PS_MODE; > + ps_mode_str =3D "auto"; > + } > + > + cc33xx_debug(cc->dev, DEBUG_PSM, "%s ps enabled\n", ps_mode_str); > + > + ret =3D cc33xx_ps_set_mode(cc, wlvif, ps_mode); > + if (ret < 0) > + dev_warn(cc->dev, "enter %s ps failed %d\n", > + ps_mode_str, ret); > + } else if (!vif->cfg.ps && test_bit(WLVIF_FLAG_IN_PS, > + &wlvif->flags)) { > + cc33xx_debug(cc->dev, DEBUG_PSM, "auto ps disabled\n"); > + > + ret =3D cc33xx_ps_set_mode(cc, wlvif, > + STATION_ACTIVE_MODE); > + if (ret < 0) > + dev_warn(cc->dev, "exit auto ps failed %d\n", ret); > + } > + } > + > + /* Handle new association with HT. Do this after join. */ > + if (sta_exists) { > + bool enabled =3D bss_conf->chanreq.oper.width !=3D > + NL80211_CHAN_WIDTH_20_NOHT; > + cc33xx_debug(cc->dev, DEBUG_CMD, "cc33xx_hw_set_peer_cap %x\n", > + wlvif->rate_set); > + ret =3D cc33xx_acx_set_peer_cap(cc, &sta_ht_cap, &sta_he_cap, > + wlvif, enabled, wlvif->rate_set); > + if (ret < 0) { > + dev_warn(cc->dev, "Set ht cap failed %d\n", ret); > + return; > + } > + > + if (enabled) { > + ret =3D cc33xx_acx_set_ht_information(cc, wlvif, > + bss_conf->ht_operation_mode, > + bss_conf->he_oper.params, > + bss_conf->he_oper.nss_set); > + if (ret < 0) { > + dev_warn(cc->dev, "Set ht information failed %d\n", > + ret); > + return; > + } > + } > + } > + > + if (changed & BSS_CHANGED_QOS) { > + WARN_ON(wlvif->bss_type !=3D BSS_TYPE_STA_BSS); > + wlvif->sta.qos =3D bss_conf->qos; > + } > +} > + > +static void cc33xx_op_bss_info_changed(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif, > + struct ieee80211_bss_conf *bss_conf, > + u64 changed) > +{ > + struct cc33xx *cc =3D hw->priv; > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + bool is_ap =3D (wlvif->bss_type =3D=3D BSS_TYPE_AP_BSS); > + int ret, set_power; > + > + /* make sure to cancel pending disconnections if our association > + * state changed > + */ > + if (!is_ap && (changed & BSS_CHANGED_ASSOC)) > + wiphy_delayed_work_cancel(cc->hw->wiphy, > + &wlvif->connection_loss_work); > + > + if (is_ap && (changed & BSS_CHANGED_BEACON_ENABLED) && > + !bss_conf->enable_beacon) > + cc33xx_tx_flush(cc); > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) > + return; > + > + if (unlikely(!test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags))) > + return; > + > + if ((changed & BSS_CHANGED_TXPOWER) && bss_conf->txpower !=3D wlvif->po= wer_level) { > + /* bss_conf->txpower is initialized with a default value, > + * meaning the power has not been set and should be ignored, use > + * max value instead > + */ > + set_power =3D (bss_conf->txpower =3D=3D INT_MIN) ? > + CC33XX_MAX_TXPWR : bss_conf->txpower; > + ret =3D cc33xx_acx_tx_power(cc, wlvif, set_power); > + > + if (ret < 0) > + return; > + } > + > + if (is_ap) > + cc33xx_bss_info_changed_ap(cc, vif, bss_conf, changed); > + else > + cc33xx_bss_info_changed_sta(cc, vif, bss_conf, changed); > +} > + > +static int cc33xx_op_add_chanctx(struct ieee80211_hw *hw, > + struct ieee80211_chanctx_conf *ctx) > +{ > + struct cc33xx *cc =3D hw->priv; > + > + cc33xx_debug(cc->dev, DEBUG_MAC80211, "mac80211 add chanctx %d (type %d= )\n", > + ieee80211_frequency_to_channel(ctx->def.chan->center_freq), > + cfg80211_get_chandef_type(&ctx->def)); > + return 0; > +} > + > +static void cc33xx_op_remove_chanctx(struct ieee80211_hw *hw, > + struct ieee80211_chanctx_conf *ctx) > +{ > + struct cc33xx *cc =3D hw->priv; > + > + cc33xx_debug(cc->dev, DEBUG_MAC80211, "mac80211 remove chanctx %d (type= %d)\n", > + ieee80211_frequency_to_channel(ctx->def.chan->center_freq), > + cfg80211_get_chandef_type(&ctx->def)); > +} > + > +static void cc33xx_op_change_chanctx(struct ieee80211_hw *hw, > + struct ieee80211_chanctx_conf *ctx, > + u32 changed) > +{ > + struct cc33xx *cc =3D hw->priv; > + struct cc33xx_vif *wlvif; > + int channel =3D ieee80211_frequency_to_channel(ctx->def.chan->center_fr= eq); > + > + cc33xx_debug(cc->dev, DEBUG_MAC80211, > + "mac80211 change chanctx %d (type %d) changed 0x%x\n", > + channel, cfg80211_get_chandef_type(&ctx->def), changed); > + > + cc33xx_for_each_wlvif(cc, wlvif) { > + struct ieee80211_vif *vif =3D cc33xx_wlvif_to_vif(wlvif); > + > + rcu_read_lock(); > + if (rcu_access_pointer(vif->bss_conf.chanctx_conf) !=3D ctx) { > + rcu_read_unlock(); > + continue; > + } > + rcu_read_unlock(); > + } > +} > + > +static int cc33xx_op_assign_vif_chanctx(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif, > + struct ieee80211_bss_conf *link_conf, > + struct ieee80211_chanctx_conf *ctx) > +{ > + struct cc33xx *cc =3D hw->priv; > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + int channel =3D ieee80211_frequency_to_channel(ctx->def.chan->center_fr= eq); > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) > + return -EPERM; > + > + if (unlikely(!test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags))) > + return -EPERM; > + > + if (ctx->def.width > NL80211_CHAN_WIDTH_20) > + return -EINVAL; > + > + wlvif->band =3D ctx->def.chan->band; > + wlvif->channel =3D channel; > + wlvif->channel_type =3D cfg80211_get_chandef_type(&ctx->def); > + > + /* update default rates according to the band */ > + cc33xx_set_band_rate(wlvif); > + > + return 0; > +} > + > +static void cc33xx_op_unassign_vif_chanctx(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif, > + struct ieee80211_bss_conf *link_conf, > + struct ieee80211_chanctx_conf *ctx) > +{ > + struct cc33xx *cc =3D hw->priv; > + > + cc33xx_tx_flush(cc); > +} > + > +static int cc33xx_switch_vif_chan(struct cc33xx *cc, struct cc33xx_vif *= wlvif, > + struct ieee80211_chanctx_conf *new_ctx) > +{ > + int channel =3D ieee80211_frequency_to_channel(new_ctx->def.chan->cente= r_freq); > + > + wlvif->band =3D new_ctx->def.chan->band; > + wlvif->channel =3D channel; > + wlvif->channel_type =3D cfg80211_get_chandef_type(&new_ctx->def); > + > + return 0; > +} > + > +static int cc33xx_op_switch_vif_chanctx(struct ieee80211_hw *hw, > + struct ieee80211_vif_chanctx_switch *vifs, > + int n_vifs, > + enum ieee80211_chanctx_switch_mode mode) > +{ > + struct cc33xx *cc =3D hw->priv; > + int i, ret; > + > + cc33xx_debug(cc->dev, DEBUG_MAC80211, > + "mac80211 switch chanctx n_vifs %d mode %d\n", n_vifs, mode); > + > + for (i =3D 0; i < n_vifs; i++) { > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vifs[i].vif); > + > + ret =3D cc33xx_switch_vif_chan(cc, wlvif, vifs[i].new_ctx); > + if (ret) > + break; > + } > + > + return 0; > +} > + > +static int cc33xx_op_conf_tx(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif, > + unsigned int link_id, u16 queue, > + const struct ieee80211_tx_queue_params *params) > +{ > + struct cc33xx *cc =3D hw->priv; > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + u8 ps_scheme; > + int ret =3D 0; > + > + if (cc33xx_is_p2p_mgmt(wlvif)) > + return 0; > + > + cc33xx_debug(cc->dev, DEBUG_MAC80211, "mac80211 conf tx %d\n", queue); > + > + if (params->uapsd) > + ps_scheme =3D CONF_PS_SCHEME_UPSD_TRIGGER; > + else > + ps_scheme =3D CONF_PS_SCHEME_LEGACY; > + > + if (!test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) > + return -EPERM; > + > + ret =3D cc33xx_tx_param_cfg(cc, wlvif, cc33xx_tx_get_queue(queue), > + params->cw_min, params->cw_max, params->aifs, > + params->txop << 5, params->acm, ps_scheme, > + params->mu_edca, params->mu_edca_param_rec.aifsn, > + params->mu_edca_param_rec.ecw_min_max, > + params->mu_edca_param_rec.mu_edca_timer); > + > + return ret; > +} > + > +static int cc33xx_op_get_survey(struct ieee80211_hw *hw, int idx, > + struct survey_info *survey) > +{ > + struct ieee80211_conf *conf =3D &hw->conf; > + > + if (idx !=3D 0) > + return -ENOENT; > + > + survey->channel =3D conf->chandef.chan; > + survey->filled =3D 0; > + return 0; > +} > + > +static int cc33xx_allocate_sta(struct cc33xx *cc, > + struct cc33xx_vif *wlvif, > + struct ieee80211_sta *sta) > +{ > + struct cc33xx_station *wl_sta; > + int ret; > + > + if (cc->active_sta_count >=3D CC33XX_MAX_AP_STATIONS) { > + dev_warn(cc->dev, "could not allocate HLID - too much stations\n"); > + return -EBUSY; > + } > + > + wl_sta =3D (struct cc33xx_station *)sta->drv_priv; > + > + ret =3D cc33xx_set_link(cc, wlvif, wl_sta->hlid); > + > + if (ret < 0) { > + dev_warn(cc->dev, "could not allocate HLID - too many links\n"); > + return -EBUSY; > + } > + > + /* use the previous security seq, if this is a recovery/resume */ > + cc->links[wl_sta->hlid].total_freed_pkts =3D wl_sta->total_freed_pkts; > + > + set_bit(wl_sta->hlid, wlvif->ap.sta_hlid_map); > + memcpy(cc->links[wl_sta->hlid].addr, sta->addr, ETH_ALEN); > + cc->active_sta_count++; > + return 0; > +} > + > +void cc33xx_free_sta(struct cc33xx *cc, struct cc33xx_vif *wlvif, u8 hli= d) > +{ > + if (!test_bit(hlid, wlvif->ap.sta_hlid_map)) > + return; > + > + clear_bit(hlid, wlvif->ap.sta_hlid_map); > + > + cc33xx_free_wlsta_info(cc, wlvif, hlid, cc->links[hlid].addr); > + > + cc33xx_clear_link(cc, wlvif, &hlid); > + cc->active_sta_count--; > +} > + > +static int cc33xx_sta_add(struct cc33xx *cc, > + struct cc33xx_vif *wlvif, > + struct ieee80211_sta *sta) > +{ > + struct cc33xx_station *wl_sta; > + int ret =3D 0; > + u8 hlid; > + > + cc33xx_debug(cc->dev, DEBUG_MAC80211, "mac80211 add sta %d\n", (int)sta= ->aid); > + > + wl_sta =3D (struct cc33xx_station *)sta->drv_priv; > + ret =3D cc33xx_cmd_add_peer(cc, wlvif, sta, &hlid, 0); > + if (ret < 0) > + return ret; > + > + wl_sta->hlid =3D hlid; > + ret =3D cc33xx_allocate_sta(cc, wlvif, sta); > + > + return ret; > +} > + > +static int cc33xx_sta_remove(struct cc33xx *cc, > + struct cc33xx_vif *wlvif, > + struct ieee80211_sta *sta) > +{ > + struct cc33xx_station *wl_sta; > + int ret =3D 0, id; > + > + cc33xx_debug(cc->dev, DEBUG_MAC80211, "mac80211 remove sta %d\n", (int)= sta->aid); > + > + wl_sta =3D (struct cc33xx_station *)sta->drv_priv; > + id =3D wl_sta->hlid; > + if (WARN_ON(!test_bit(id, wlvif->ap.sta_hlid_map))) > + return -EINVAL; > + > + ret =3D cc33xx_cmd_remove_peer(cc, wlvif, wl_sta->hlid); > + if (ret < 0) > + return ret; > + > + cc33xx_free_sta(cc, wlvif, wl_sta->hlid); > + return ret; > +} > + > +static void cc33xx_roc_if_possible(struct cc33xx *cc, struct cc33xx_vif = *wlvif) > +{ > + if (find_first_bit(cc->roc_map, CC33XX_MAX_ROLES) < CC33XX_MAX_ROLES) > + return; > + > + if (WARN_ON(wlvif->role_id =3D=3D CC33XX_INVALID_ROLE_ID)) > + return; > + > + cc33xx_roc(cc, wlvif, wlvif->role_id, wlvif->band, wlvif->channel); > +} > + > +/* The FW must be awake when the call takes place. > + */ > +void cc33xx_update_inconn_sta(struct cc33xx *cc, struct cc33xx_vif *wlvi= f, > + struct cc33xx_station *wl_sta, bool in_conn) > +{ > + cc33xx_debug(cc->dev, DEBUG_CMD, "update_inconn_sta: in_conn=3D%d count= =3D%d\n", > + in_conn, wlvif->inconn_count); > + > + if (!wl_sta) > + return; > + > + if (in_conn) { > + if (WARN_ON(wl_sta->in_connection)) > + return; > + > + if (!wlvif->inconn_count) { > + cc33xx_roc_if_possible(cc, wlvif); > + if (test_bit(wlvif->role_id, cc->roc_map)) { > + unsigned long roc_cmplt_jiffies =3D > + msecs_to_jiffies(ROC_PENDING_COMPLETE_TIMEOUT); > + > + cc33xx_debug(cc->dev, DEBUG_AP, "delay queue roc_timeout_work\n"); > + > + wiphy_delayed_work_queue(cc->hw->wiphy, > + &wlvif->roc_timeout_work, > + roc_cmplt_jiffies); > + } > + } > + > + wl_sta->in_connection =3D true; > + wlvif->inconn_count++; > + } else { > + if (!wl_sta->in_connection) > + return; > + > + if (WARN_ON(!wlvif->inconn_count)) > + return; > + > + wl_sta->in_connection =3D false; > + wlvif->inconn_count--; > + > + if (!wlvif->inconn_count && > + test_bit(wlvif->role_id, cc->roc_map)) { > + cc33xx_croc(cc, wlvif->role_id); > + /* remove timer for croc t/o */ > + cc33xx_debug(cc->dev, DEBUG_AP, "Cancel pending_roc timeout\n"); > + wiphy_delayed_work_cancel(cc->hw->wiphy, > + &wlvif->roc_timeout_work); > + } > + } > +} > + > +static int cc33xx_update_sta_state(struct cc33xx *cc, > + struct cc33xx_vif *wlvif, > + struct ieee80211_sta *sta, > + enum ieee80211_sta_state old_state, > + enum ieee80211_sta_state new_state) > +{ > + struct cc33xx_station *wl_sta; > + bool is_ap =3D wlvif->bss_type =3D=3D BSS_TYPE_AP_BSS; > + bool is_sta =3D wlvif->bss_type =3D=3D BSS_TYPE_STA_BSS; > + int ret; > + > + wl_sta =3D (struct cc33xx_station *)sta->drv_priv; > + > + /* Add station (AP mode) */ > + if (is_ap && old_state =3D=3D IEEE80211_STA_NOTEXIST && new_state =3D= =3D IEEE80211_STA_NONE) { > + ret =3D cc33xx_sta_add(cc, wlvif, sta); > + if (ret) > + return ret; > + > + cc33xx_update_inconn_sta(cc, wlvif, wl_sta, true); > + } > + > + /* Remove station (AP mode) */ > + if (is_ap && old_state =3D=3D IEEE80211_STA_NONE && new_state =3D=3D IE= EE80211_STA_NOTEXIST) { > + /* must not fail */ > + cc33xx_sta_remove(cc, wlvif, sta); > + > + cc33xx_update_inconn_sta(cc, wlvif, wl_sta, false); > + } > + > + /* Authorize station (AP mode) */ > + if (is_ap && new_state =3D=3D IEEE80211_STA_AUTHORIZED) { > + /* reconfigure peer */ > + ret =3D cc33xx_cmd_add_peer(cc, wlvif, sta, NULL, true); > + if (ret < 0) > + return ret; > + > + cc33xx_update_inconn_sta(cc, wlvif, wl_sta, false); > + } > + > + /* Authorize station */ > + if (is_sta && new_state =3D=3D IEEE80211_STA_AUTHORIZED) { > + set_bit(WLVIF_FLAG_STA_AUTHORIZED, &wlvif->flags); > + ret =3D cc33xx_set_authorized(cc, wlvif); > + if (ret) > + return ret; > + } > + > + if (is_sta && old_state =3D=3D IEEE80211_STA_AUTHORIZED && new_state = =3D=3D IEEE80211_STA_ASSOC) { > + clear_bit(WLVIF_FLAG_STA_AUTHORIZED, &wlvif->flags); > + clear_bit(WLVIF_FLAG_STA_STATE_SENT, &wlvif->flags); > + } > + > + /* save seq number on disassoc (suspend) */ > + if (is_sta && old_state =3D=3D IEEE80211_STA_ASSOC && new_state =3D=3D = IEEE80211_STA_AUTH) { > + cc33xx_save_freed_pkts(cc, wlvif->sta.hlid, wl_sta); > + wlvif->total_freed_pkts =3D 0; > + } > + > + /* restore seq number on assoc (resume) */ > + if (is_sta && old_state =3D=3D IEEE80211_STA_AUTH && new_state =3D=3D I= EEE80211_STA_ASSOC) > + wlvif->total_freed_pkts =3D wl_sta->total_freed_pkts; > + > + /* clear ROCs on failure or authorization */ > + if (is_sta && > + (new_state =3D=3D IEEE80211_STA_AUTHORIZED || > + new_state =3D=3D IEEE80211_STA_NOTEXIST)) { > + if (test_bit(wlvif->role_id, cc->roc_map)) > + cc33xx_croc(cc, wlvif->role_id); > + } > + > + if (is_sta && (old_state =3D=3D IEEE80211_STA_NOTEXIST && > + new_state =3D=3D IEEE80211_STA_NONE)) { > + if (find_first_bit(cc->roc_map, > + CC33XX_MAX_ROLES) >=3D CC33XX_MAX_ROLES) { > + WARN_ON(wlvif->role_id =3D=3D CC33XX_INVALID_ROLE_ID); > + cc33xx_roc(cc, wlvif, wlvif->role_id, > + wlvif->band, wlvif->channel); > + } > + } > + > + return 0; > +} > + > +static int cc33xx_op_sta_state(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif, > + struct ieee80211_sta *sta, > + enum ieee80211_sta_state old_state, > + enum ieee80211_sta_state new_state) > +{ > + struct cc33xx *cc =3D hw->priv; > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + int ret; > + > + cc33xx_debug(cc->dev, DEBUG_MAC80211, "mac80211 sta %d state=3D%d->%d\n= ", > + sta->aid, old_state, new_state); > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) > + return 0; > + > + ret =3D cc33xx_update_sta_state(cc, wlvif, sta, old_state, new_state); > + > + if (new_state < old_state) > + return 0; > + return ret; > +} > + > +static int cc33xx_op_ampdu_action(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif, > + struct ieee80211_ampdu_params *params) > +{ > + struct cc33xx *cc =3D hw->priv; > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + int ret; > + u8 hlid, *ba_bitmap; > + struct ieee80211_sta *sta =3D params->sta; > + enum ieee80211_ampdu_mlme_action action =3D params->action; > + u16 tid =3D params->tid; > + u16 *ssn =3D ¶ms->ssn; > + > + /* sanity check - the fields in FW are only 8bits wide */ > + if (WARN_ON(tid > 0xFF)) > + return -EOPNOTSUPP; > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) > + return 0; > + > + if (wlvif->bss_type =3D=3D BSS_TYPE_STA_BSS) { > + hlid =3D wlvif->sta.hlid; > + } else if (wlvif->bss_type =3D=3D BSS_TYPE_AP_BSS) { > + struct cc33xx_station *wl_sta; > + > + wl_sta =3D (struct cc33xx_station *)sta->drv_priv; > + hlid =3D wl_sta->hlid; > + } else { > + return -EINVAL; > + } > + > + if (hlid =3D=3D CC33XX_INVALID_LINK_ID) > + return 0; > + > + if (WARN_ON(hlid >=3D CC33XX_MAX_LINKS)) > + return -EINVAL; > + > + ba_bitmap =3D &cc->links[hlid].ba_bitmap; > + > + switch (action) { > + case IEEE80211_AMPDU_RX_START: > + if (!wlvif->ba_support || !wlvif->ba_allowed) { > + ret =3D -EOPNOTSUPP; > + break; > + } > + > + if (cc->ba_rx_session_count >=3D CC33XX_RX_BA_MAX_SESSIONS) { > + ret =3D -EBUSY; > + dev_err(cc->dev, "exceeded max RX BA sessions\n"); > + break; > + } > + > + if (*ba_bitmap & BIT(tid)) { > + ret =3D -EINVAL; > + dev_err(cc->dev, "cannot enable RX BA session on active tid: %d\n", > + tid); > + break; > + } > + > + ret =3D cc33xx_acx_set_ba_receiver_session(cc, tid, *ssn, > + true, hlid, > + params->buf_size); > + > + if (!ret) { > + *ba_bitmap |=3D BIT(tid); > + cc->ba_rx_session_count++; > + } > + break; > + > + case IEEE80211_AMPDU_RX_STOP: > + if (!(*ba_bitmap & BIT(tid))) { > + /* this happens on reconfig - so only output a debug > + * message for now, and don't fail the function. > + */ > + cc33xx_debug(cc->dev, DEBUG_MAC80211, > + "no active RX BA session on tid: %d\n", tid); > + ret =3D 0; > + break; > + } > + > + ret =3D cc33xx_acx_set_ba_receiver_session(cc, tid, 0, > + false, hlid, 0); > + if (!ret) { > + *ba_bitmap &=3D ~BIT(tid); > + cc->ba_rx_session_count--; > + } > + break; > + > + /* The BA initiator session management in FW independently. > + * Falling break here on purpose for all TX APDU commands. > + */ > + case IEEE80211_AMPDU_TX_START: > + case IEEE80211_AMPDU_TX_STOP_CONT: > + case IEEE80211_AMPDU_TX_STOP_FLUSH: > + case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: > + case IEEE80211_AMPDU_TX_OPERATIONAL: > + ret =3D -EINVAL; > + break; > + > + default: > + dev_err(cc->dev, "Incorrect ampdu action id=3D%x\n\n", action); > + ret =3D -EINVAL; > + } > + > + return ret; > +} > + > +static int cc33xx_set_bitrate_mask(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif, > + const struct cfg80211_bitrate_mask *mask) > +{ > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + struct cc33xx *cc =3D hw->priv; > + > + cc33xx_debug(cc->dev, DEBUG_MAC80211, "mac80211 set_bitrate_mask 0x%x 0= x%x\n", > + mask->control[NL80211_BAND_2GHZ].legacy, > + mask->control[NL80211_BAND_5GHZ].legacy); > + > + wlvif->bitrate_masks[0] =3D cc33xx_tx_enabled_rates_get(cc, > + mask->control[0].legacy, 0); > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) > + return 0; > + > + if (wlvif->bss_type =3D=3D BSS_TYPE_STA_BSS && > + !test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) { > + cc33xx_set_band_rate(wlvif); > + wlvif->basic_rate =3D cc33xx_tx_min_rate_get(wlvif->basic_rate_set); > + } > + > + return 0; > +} > + > +static void cc33xx_op_channel_switch(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif, > + struct ieee80211_channel_switch *ch_switch) > +{ > + struct cc33xx *cc =3D hw->priv; > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + int ret; > + > + cc33xx_tx_flush(cc); > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) { > + if (cc->state =3D=3D CC33XX_STATE_OFF && > + test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) > + ieee80211_chswitch_done(vif, false, 0); > + return; > + } > + > + if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) { > + unsigned long delay_usec; > + > + ret =3D cc33xx_cmd_channel_switch(cc, wlvif, ch_switch); > + if (ret) > + return; > + > + set_bit(WLVIF_FLAG_CS_PROGRESS, &wlvif->flags); > + > + /* indicate failure 5 seconds after channel switch time */ > + delay_usec =3D ieee80211_tu_to_usec(wlvif->beacon_int) * > + ch_switch->count; > + wiphy_delayed_work_queue(hw->wiphy, &wlvif->channel_switch_work, > + usecs_to_jiffies(delay_usec) + > + msecs_to_jiffies(5000)); > + } > +} > + > +static void cc33xx_op_channel_switch_beacon(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif, > + struct cfg80211_chan_def *chandef) > +{ > + struct cc33xx *cc =3D hw->priv; > + > + dev_err(cc->dev, "AP channel switch is not supported\n"); > +} > + > +static void cc33xx_op_flush(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif, > + u32 queues, bool drop) > +{ > + cc33xx_tx_flush(hw->priv); > +} > + > +static int cc33xx_op_remain_on_channel(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif, > + struct ieee80211_channel *chan, > + int duration, > + enum ieee80211_roc_type type) > +{ > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + struct cc33xx *cc =3D hw->priv; > + int channel, active_roc, ret =3D 0; > + > + channel =3D ieee80211_frequency_to_channel(chan->center_freq); > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) > + return -EINVAL; > + > + /* return EBUSY if we can't ROC right now */ > + active_roc =3D find_first_bit(cc->roc_map, CC33XX_MAX_ROLES); > + if (cc->roc_vif || active_roc < CC33XX_MAX_ROLES) { > + dev_warn(cc->dev, "active roc on role %d\n", active_roc); > + return -EBUSY; > + } > + > + cc33xx_debug(cc->dev, DEBUG_MAC80211, > + "call cc33xx_start_dev, band =3D %d, channel =3D %d\n", > + chan->band, channel); > + ret =3D cc33xx_start_dev(cc, wlvif, chan->band, channel); > + if (ret < 0) > + return ret; > + > + cc->roc_vif =3D vif; > + > + wiphy_delayed_work_queue(hw->wiphy, &cc->roc_complete_work, > + msecs_to_jiffies(duration)); > + > + return ret; > +} > + > +static int __cc33xx_roc_completed(struct cc33xx *cc) > +{ > + struct cc33xx_vif *wlvif; > + int ret; > + > + /* already completed */ > + if (unlikely(!cc->roc_vif)) > + return 0; > + > + wlvif =3D cc33xx_vif_to_data(cc->roc_vif); > + > + if (!test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) > + return -EBUSY; > + > + ret =3D cc33xx_stop_dev(cc, wlvif); > + if (ret < 0) > + return ret; > + > + cc->roc_vif =3D NULL; > + > + return 0; > +} > + > +static int cc33xx_roc_completed(struct cc33xx *cc) > +{ > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) > + return -EBUSY; > + > + return __cc33xx_roc_completed(cc); > +} > + > +static void cc33xx_roc_complete_work(struct wiphy *wiphy, > + struct wiphy_work *work) > + > +{ > + struct cc33xx *cc; > + int ret; > + > + cc =3D container_of(work, struct cc33xx, roc_complete_work.work); > + > + ret =3D cc33xx_roc_completed(cc); > + if (!ret) > + ieee80211_remain_on_channel_expired(cc->hw); > +} > + > +static int cc33xx_op_cancel_remain_on_channel(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif) > +{ > + struct cc33xx *cc =3D hw->priv; > + > + cc33xx_tx_flush(cc); > + > + wiphy_delayed_work_cancel(cc->hw->wiphy, &cc->roc_complete_work); > + cc33xx_roc_completed(cc); > + > + return 0; > +} > + > +static void cc33xx_op_sta_statistics(struct ieee80211_hw *hw, > + struct ieee80211_vif *vif, > + struct ieee80211_sta *sta, > + struct station_info *sinfo) > +{ > + struct cc33xx *cc =3D hw->priv; > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + s8 rssi_dbm; > + int ret; > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) > + return; > + > + ret =3D cc33xx_acx_average_rssi(cc, wlvif, &rssi_dbm); > + if (ret < 0) > + return; > + > + sinfo->filled |=3D BIT_ULL(NL80211_STA_INFO_SIGNAL); > + sinfo->signal =3D rssi_dbm; > + > + ret =3D cc33xx_acx_get_tx_rate(cc, wlvif, sinfo); > + if (ret < 0) > + return; > +} > + > +static u32 cc33xx_op_get_expected_throughput(struct ieee80211_hw *hw, > + struct ieee80211_sta *sta) > +{ > + struct cc33xx_station *wl_sta =3D (struct cc33xx_station *)sta->drv_pri= v; > + struct cc33xx *cc =3D hw->priv; > + u8 hlid =3D wl_sta->hlid; > + > + /* return in units of Kbps */ > + return (cc->links[hlid].fw_rate_mbps * 1000); > +} > + > +static bool cc33xx_tx_frames_pending(struct ieee80211_hw *hw) > +{ > + struct cc33xx *cc =3D hw->priv; > + bool ret; > + > + if (unlikely(cc->state !=3D CC33XX_STATE_ON)) > + return false; > + > + guard(mutex)(&cc->mutex); > + /* packets are considered pending if in the TX queue or the FW */ > + ret =3D (cc33xx_tx_total_queue_count(cc) > 0) || (cc->tx_frames_cnt > 0= ); > + > + return ret; > +} > + > +#ifdef CONFIG_PM > + > +static const struct wiphy_wowlan_support cc33xx_wowlan_support =3D { > + .flags =3D WIPHY_WOWLAN_ANY, > + .n_patterns =3D CC33XX_MAX_RX_FILTERS, > + .pattern_min_len =3D 1, > + .pattern_max_len =3D RX_FILTER_MAX_PATTERN_SIZE, > +}; > + > +static void setup_wake_irq(struct cc33xx *cc) > +{ > + struct platform_device *pdev =3D cc->pdev; > + struct cc33xx_platdev_data *pdev_data =3D dev_get_platdata(&pdev->dev); > + > + struct resource *res; > + int ret; > + > + device_init_wakeup(cc->dev, true); > + > + if (pdev_data->pwr_in_suspend) > + cc->hw->wiphy->wowlan =3D &cc33xx_wowlan_support; > + > + res =3D platform_get_resource(pdev, IORESOURCE_IRQ, 0); > + if (res) { > + cc->wakeirq =3D res->start; > + ret =3D dev_pm_set_dedicated_wake_irq(cc->dev, cc->wakeirq); > + if (ret) > + cc->wakeirq =3D -ENODEV; > + } else { > + cc->wakeirq =3D -ENODEV; > + } > + > + cc->keep_device_power =3D true; > +} > +#else > + > +static inline void setup_wake_irq(struct cc33xx *cc) > +{ > + cc->keep_device_power =3D true; > +} > + > +#endif /* CONFIG_PM */ > + > +static const struct ieee80211_ops cc33xx_ops =3D { > + .start =3D cc33xx_op_start, > + .stop =3D cc33xx_op_stop, > + .add_interface =3D cc33xx_op_add_interface, > + .remove_interface =3D cc33xx_op_remove_interface, > + .change_interface =3D cc33xx_op_change_interface, > +#ifdef CONFIG_PM > + .suspend =3D cc33xx_op_suspend, > + .resume =3D cc33xx_op_resume, > +#endif > + .prepare_multicast =3D cc33xx_op_prepare_multicast, > + .configure_filter =3D cc33xx_op_configure_filter, > + .tx =3D cc33xx_op_tx, > + .wake_tx_queue =3D cc33xx_handle_wake_tx_queue, > + .set_key =3D cc33xx_op_set_key, > + .hw_scan =3D cc33xx_op_hw_scan, > + .cancel_hw_scan =3D cc33xx_op_cancel_hw_scan, > + .sched_scan_start =3D cc33xx_op_sched_scan_start, > + .sched_scan_stop =3D cc33xx_op_sched_scan_stop, > + .bss_info_changed =3D cc33xx_op_bss_info_changed, > + .set_frag_threshold =3D cc33xx_op_set_frag_threshold, > + .set_rts_threshold =3D cc33xx_op_set_rts_threshold, > + .conf_tx =3D cc33xx_op_conf_tx, > + .get_survey =3D cc33xx_op_get_survey, > + .sta_state =3D cc33xx_op_sta_state, > + .ampdu_action =3D cc33xx_op_ampdu_action, > + .tx_frames_pending =3D cc33xx_tx_frames_pending, > + .set_bitrate_mask =3D cc33xx_set_bitrate_mask, > + .set_default_unicast_key =3D cc33xx_op_set_default_key_idx, > + .channel_switch =3D cc33xx_op_channel_switch, > + .channel_switch_beacon =3D cc33xx_op_channel_switch_beacon, > + .flush =3D cc33xx_op_flush, > + .remain_on_channel =3D cc33xx_op_remain_on_channel, > + .cancel_remain_on_channel =3D cc33xx_op_cancel_remain_on_channel, > + .add_chanctx =3D cc33xx_op_add_chanctx, > + .remove_chanctx =3D cc33xx_op_remove_chanctx, > + .change_chanctx =3D cc33xx_op_change_chanctx, > + .assign_vif_chanctx =3D cc33xx_op_assign_vif_chanctx, > + .unassign_vif_chanctx =3D cc33xx_op_unassign_vif_chanctx, > + .switch_vif_chanctx =3D cc33xx_op_switch_vif_chanctx, > + .sta_statistics =3D cc33xx_op_sta_statistics, > + .get_expected_throughput =3D cc33xx_op_get_expected_throughput, > + CFG80211_TESTMODE_CMD(cc33xx_tm_cmd) > +}; > + > +u8 cc33xx_rate_to_idx(u8 rate, enum nl80211_band band) > +{ > + if (WARN_ON(band > NL80211_BAND_5GHZ)) > + return 0; > + > + if (unlikely(rate > CONF_HW_RATE_INDEX_MAX)) > + return CONF_HW_RXTX_RATE_UNSUPPORTED; > + > + return cc33xx_band_rate_to_idx[band][rate]; > +} > + > +static void cc33xx_derive_mac_addresses(struct cc33xx *cc) > +{ > + const u8 zero_mac[ETH_ALEN] =3D {0}; > + u8 base_addr[ETH_ALEN]; > + u8 bd_addr[ETH_ALEN]; > + > + if (!ether_addr_equal(zero_mac, cc->efuse_mac_address)) { > + u8 oui_laa_bit =3D BIT(1); > + u8 oui_multicast_bit =3D BIT(0); > + > + cc33xx_debug(cc->dev, DEBUG_BOOT, > + "MAC address derived from EFUSE\n"); > + ether_addr_copy(base_addr, cc->efuse_mac_address); > + > + base_addr[0] &=3D ~oui_multicast_bit; > + > + ether_addr_copy(cc->addresses[0].addr, base_addr); > + ether_addr_copy(cc->addresses[1].addr, base_addr); > + ether_addr_copy(cc->addresses[2].addr, base_addr); > + ether_addr_copy(bd_addr, base_addr); > + > + cc->addresses[1].addr[0] |=3D oui_laa_bit; > + cc->addresses[2].addr[0] |=3D oui_laa_bit; > + > + eth_addr_inc(cc->addresses[2].addr); > + eth_addr_inc(bd_addr); > + } else { > + dev_warn(cc->dev, "No EFUSE data, using random locally administered ad= dress.\n"); > + eth_random_addr(base_addr); > + > + ether_addr_copy(cc->addresses[0].addr, base_addr); > + ether_addr_copy(cc->addresses[1].addr, base_addr); > + ether_addr_copy(cc->addresses[2].addr, base_addr); > + ether_addr_copy(bd_addr, base_addr); > + > + eth_addr_inc(bd_addr); > + eth_addr_inc(cc->addresses[1].addr); > + eth_addr_inc(cc->addresses[1].addr); > + eth_addr_inc(cc->addresses[2].addr); > + eth_addr_inc(cc->addresses[2].addr); > + eth_addr_inc(cc->addresses[2].addr); > + } > + > + cc->hw->wiphy->n_addresses =3D CC33XX_NUM_MAC_ADDRESSES; > + cc->hw->wiphy->addresses =3D cc->addresses; > + > + cc33xx_cmd_set_bd_addr(cc, bd_addr); > +} > + > +static int cc33xx_register_hw(struct cc33xx *cc) > +{ > + int ret; > + > + if (cc->mac80211_registered) > + return 0; > + > + cc33xx_derive_mac_addresses(cc); > + > + ret =3D ieee80211_register_hw(cc->hw); > + if (ret < 0) { > + dev_err(cc->dev, "unable to register mac80211 hw: %d\n", ret); > + return ret; > + } > + > + cc->mac80211_registered =3D true; > + > + return ret; > +} > + > +static void cc33xx_unregister_hw(struct cc33xx *cc) > +{ > + if (cc->plt) > + cc33xx_plt_stop(cc); > + > + ieee80211_unregister_hw(cc->hw); > + cc->mac80211_registered =3D false; > +} > + > +static int cc33xx_init_ieee80211(struct cc33xx *cc) > +{ > + unsigned int i; > + > + if (cc->conf.core.mixed_mode_support) { > + static const u32 cipher_suites[] =3D { > + WLAN_CIPHER_SUITE_CCMP, > + WLAN_CIPHER_SUITE_AES_CMAC, > + WLAN_CIPHER_SUITE_TKIP, > + WLAN_CIPHER_SUITE_GCMP, > + WLAN_CIPHER_SUITE_GCMP_256, > + WLAN_CIPHER_SUITE_BIP_GMAC_128, > + WLAN_CIPHER_SUITE_BIP_GMAC_256, > + }; > + cc->hw->wiphy->cipher_suites =3D cipher_suites; > + cc->hw->wiphy->n_cipher_suites =3D ARRAY_SIZE(cipher_suites); > + > + } else { > + static const u32 cipher_suites[] =3D { > + WLAN_CIPHER_SUITE_CCMP, > + WLAN_CIPHER_SUITE_AES_CMAC, > + WLAN_CIPHER_SUITE_GCMP, > + WLAN_CIPHER_SUITE_GCMP_256, > + WLAN_CIPHER_SUITE_BIP_GMAC_128, > + WLAN_CIPHER_SUITE_BIP_GMAC_256, > + }; > + cc->hw->wiphy->cipher_suites =3D cipher_suites; > + cc->hw->wiphy->n_cipher_suites =3D ARRAY_SIZE(cipher_suites); > + } > + > + /* The tx descriptor buffer */ > + cc->hw->extra_tx_headroom =3D CC33XX_TX_EXTRA_HEADROOM; > + > + if (cc->quirks & CC33XX_QUIRK_TKIP_HEADER_SPACE) > + cc->hw->extra_tx_headroom +=3D CC33XX_EXTRA_SPACE_TKIP; > + > + /* unit us */ > + /* FIXME: find a proper value */ > + cc->hw->max_listen_interval =3D > + cc->conf.host_conf.conn.max_listen_interval; > + > + ieee80211_hw_set(cc->hw, SUPPORT_FAST_XMIT); > + ieee80211_hw_set(cc->hw, CHANCTX_STA_CSA); > + ieee80211_hw_set(cc->hw, QUEUE_CONTROL); > + ieee80211_hw_set(cc->hw, TX_AMPDU_SETUP_IN_HW); > + ieee80211_hw_set(cc->hw, AMPDU_AGGREGATION); > + ieee80211_hw_set(cc->hw, AP_LINK_PS); > + ieee80211_hw_set(cc->hw, SPECTRUM_MGMT); > + ieee80211_hw_set(cc->hw, REPORTS_TX_ACK_STATUS); > + ieee80211_hw_set(cc->hw, CONNECTION_MONITOR); > + ieee80211_hw_set(cc->hw, HAS_RATE_CONTROL); > + ieee80211_hw_set(cc->hw, SUPPORTS_DYNAMIC_PS); > + ieee80211_hw_set(cc->hw, SIGNAL_DBM); > + ieee80211_hw_set(cc->hw, SUPPORTS_PS); > + ieee80211_hw_set(cc->hw, SUPPORTS_TX_FRAG); > + ieee80211_hw_set(cc->hw, SUPPORTS_MULTI_BSSID); > + ieee80211_hw_set(cc->hw, SUPPORTS_AMSDU_IN_AMPDU); > + > + cc->hw->wiphy->interface_modes =3D cc33xx_wiphy_interface_modes(); > + > + cc->hw->wiphy->max_scan_ssids =3D 1; > + cc->hw->wiphy->max_sched_scan_ssids =3D 16; > + cc->hw->wiphy->max_match_sets =3D 16; > + /* Maximum length of elements in scanning probe request templates > + * should be the maximum length possible for a template, without > + * the IEEE80211 header of the template > + */ > + cc->hw->wiphy->max_scan_ie_len =3D CC33XX_CMD_TEMPL_MAX_SIZE - > + sizeof(struct ieee80211_header); > + > + cc->hw->wiphy->max_sched_scan_reqs =3D 1; > + cc->hw->wiphy->max_sched_scan_ie_len =3D CC33XX_CMD_TEMPL_MAX_SIZE - > + sizeof(struct ieee80211_header); > + > + cc->hw->wiphy->max_remain_on_channel_duration =3D 30000; > + > + cc->hw->wiphy->features |=3D NL80211_FEATURE_AP_SCAN; > + > + /* We keep local copies of the band structs because we need to > + * modify them on a per-device basis. > + */ > + memcpy(&cc->bands[NL80211_BAND_2GHZ], &cc33xx_band_2ghz, > + sizeof(cc33xx_band_2ghz)); > + memcpy(&cc->bands[NL80211_BAND_2GHZ].ht_cap, > + &cc->ht_cap[NL80211_BAND_2GHZ], > + sizeof(*cc->ht_cap)); > + > + memcpy(&cc->bands[NL80211_BAND_5GHZ], &cc33xx_band_5ghz, > + sizeof(cc33xx_band_5ghz)); > + memcpy(&cc->bands[NL80211_BAND_5GHZ].ht_cap, > + &cc->ht_cap[NL80211_BAND_5GHZ], > + sizeof(*cc->ht_cap)); > + > + /* clear channel flags from the previous usage > + * and restore max_power & max_antenna_gain values. > + */ > + for (i =3D 0; i < ARRAY_SIZE(cc33xx_channels); i++) { > + cc->bands[NL80211_BAND_2GHZ].channels[i].flags =3D 0; > + cc->bands[NL80211_BAND_2GHZ].channels[i].max_power =3D CC33XX_MAX_TXPW= R; > + cc->bands[NL80211_BAND_2GHZ].channels[i].max_antenna_gain =3D 0; > + } > + > + for (i =3D 0; i < ARRAY_SIZE(cc33xx_channels_5ghz); i++) { > + cc->bands[NL80211_BAND_5GHZ].channels[i].flags =3D 0; > + cc->bands[NL80211_BAND_5GHZ].channels[i].max_power =3D CC33XX_MAX_TXPW= R; > + cc->bands[NL80211_BAND_5GHZ].channels[i].max_antenna_gain =3D 0; > + } > + > + /* Enable/Disable He based on conf file params */ > + if (!cc->conf.mac.he_enable) { > + cc->bands[NL80211_BAND_2GHZ].iftype_data =3D NULL; > + cc->bands[NL80211_BAND_2GHZ].n_iftype_data =3D 0; > + > + cc->bands[NL80211_BAND_5GHZ].iftype_data =3D NULL; > + cc->bands[NL80211_BAND_5GHZ].n_iftype_data =3D 0; > + } > + > + ieee80211_set_sband_iftype_data(&cc->bands[NL80211_BAND_2GHZ], iftype_d= ata_2ghz); > + ieee80211_set_sband_iftype_data(&cc->bands[NL80211_BAND_5GHZ], iftype_d= ata_5ghz); > + > + cc->hw->wiphy->bands[NL80211_BAND_2GHZ] =3D > + &cc->bands[NL80211_BAND_2GHZ]; > + > + if (!cc->disable_5g && cc->conf.core.enable_5ghz) > + cc->hw->wiphy->bands[NL80211_BAND_5GHZ] =3D > + &cc->bands[NL80211_BAND_5GHZ]; > + > + /* allow 4 queues per mac address we support + > + * 1 cab queue per mac + one global offchannel Tx queue > + */ > + cc->hw->queues =3D (NUM_TX_QUEUES + 1) * CC33XX_NUM_MAC_ADDRESSES + 1; > + > + /* the last queue is the offchannel queue */ > + cc->hw->offchannel_tx_hw_queue =3D cc->hw->queues - 1; > + cc->hw->max_rates =3D 1; > + > + /* allowed interface combinations */ > + cc->hw->wiphy->iface_combinations =3D cc33xx_iface_combinations; > + cc->hw->wiphy->n_iface_combinations =3D ARRAY_SIZE(cc33xx_iface_combina= tions); > + > + SET_IEEE80211_DEV(cc->hw, cc->dev); > + > + cc->hw->sta_data_size =3D sizeof(struct cc33xx_station); > + cc->hw->vif_data_size =3D sizeof(struct cc33xx_vif); > + > + cc->hw->max_rx_aggregation_subframes =3D cc->conf.host_conf.ht.rx_ba_wi= n_size; > + > + /* For all ps schemes don't use UAPSD, except for UAPSD scheme > + * As these are the currently supportedd PS schemes, use the default > + * legacy otherwise > + */ > + if (cc->conf.mac.ps_scheme =3D=3D PS_SCHEME_UPSD_TRIGGER) { > + cc->hw->uapsd_queues =3D IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK; > + } else if ((cc->conf.mac.ps_scheme !=3D PS_SCHEME_LEGACY) && > + (cc->conf.mac.ps_scheme !=3D PS_SCHEME_NOPSPOLL)) { > + cc->hw->uapsd_queues =3D 0; > + cc->conf.mac.ps_scheme =3D PS_SCHEME_LEGACY; > + } else { > + cc->hw->uapsd_queues =3D 0; > + } > + > + return 0; > +} > + > +static struct ieee80211_hw *cc33xx_alloc_hw(void) > +{ > + struct ieee80211_hw *hw; > + struct cc33xx *cc; > + int i, j; > + unsigned int order; > + > + hw =3D ieee80211_alloc_hw(sizeof(*cc), &cc33xx_ops); > + if (!hw) > + return NULL; > + > + cc =3D hw->priv; > + memset(cc, 0, sizeof(*cc)); > + > + INIT_LIST_HEAD(&cc->wlvif_list); > + > + cc->hw =3D hw; > + > + /* cc->num_links is not configured yet, so just use CC33XX_MAX_LINKS. > + * we don't allocate any additional resource here, so that's fine. > + */ > + for (j =3D 0; j < CC33XX_MAX_LINKS; j++) > + skb_queue_head_init(&cc->links[j].tx_pending); > + > + skb_queue_head_init(&cc->deferred_rx_queue); > + skb_queue_head_init(&cc->deferred_tx_queue); > + > + init_llist_head(&cc->event_list); > + > + INIT_WORK(&cc->netstack_work, cc33xx_netstack_work); > + INIT_WORK(&cc->tx_work, cc33xx_tx_work); > + INIT_WORK(&cc->recovery_work, cc33xx_recovery_work); > + INIT_WORK(&cc->irq_deferred_work, irq_deferred_work); > + wiphy_delayed_work_init(&cc->scan_complete_work, cc33xx_scan_complete_w= ork); > + wiphy_delayed_work_init(&cc->roc_complete_work, cc33xx_roc_complete_wor= k); > + > + cc->freezable_netstack_wq =3D create_freezable_workqueue("cc33xx_netsta= ck_wq"); > + if (!cc->freezable_netstack_wq) > + goto err_hw_alloc; > + > + cc->freezable_wq =3D alloc_workqueue("cc33xx_wq", __WQ_LEGACY | > + WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM | > + WQ_HIGHPRI, 1); > + > + if (!cc->freezable_wq) > + goto err_ns_wq; > + > + cc->rx_counter =3D 0; > + cc->flags =3D 0; > + cc->sleep_auth =3D CC33XX_PSM_ILLEGAL; > + > + cc->quirks =3D 0; > + cc->active_sta_count =3D 0; > + cc->active_link_count =3D 0; > + > + /* The system link is always allocated */ > + __set_bit(CC33XX_SYSTEM_HLID, cc->links_map); > + > + memset(cc->tx_frames_map, 0, sizeof(cc->tx_frames_map)); > + for (i =3D 0; i < CC33XX_NUM_TX_DESCRIPTORS; i++) > + cc->tx_frames[i] =3D NULL; > + > + spin_lock_init(&cc->cc_lock); > + > + cc->state =3D CC33XX_STATE_OFF; > + mutex_init(&cc->mutex); > + mutex_init(&cc->cmd_lock); > + > + order =3D get_order(CC33XX_AGGR_BUFFER_SIZE); > + cc->aggr_buf =3D (u8 *)__get_free_pages(GFP_KERNEL, order); > + if (!cc->aggr_buf) > + goto err_all_wq; > + > + cc->aggr_buf_size =3D CC33XX_AGGR_BUFFER_SIZE; > + > + cc->core_status =3D kzalloc_obj(*cc->core_status); > + if (!cc->core_status) > + goto err_aggr; > + > + return hw; > + > +err_aggr: > + free_pages((unsigned long)cc->aggr_buf, order); > + > +err_all_wq: > + destroy_workqueue(cc->freezable_wq); > + > +err_ns_wq: > + destroy_workqueue(cc->freezable_netstack_wq); > + > +err_hw_alloc: > + ieee80211_free_hw(cc->hw); > + > + return NULL; > +} > + > +static int cc33xx_free_hw(struct cc33xx *cc) > +{ > + kfree(cc->core_status); > + free_pages((unsigned long)cc->aggr_buf, get_order(cc->aggr_buf_size)); > + > + destroy_workqueue(cc->freezable_wq); > + destroy_workqueue(cc->freezable_netstack_wq); > + flush_deferred_event_list(cc); > + > + ieee80211_free_hw(cc->hw); > + > + return 0; > +} > + > +static int cc33xx_identify_chip(struct cc33xx *cc) > +{ > + cc->quirks |=3D CC33XX_QUIRK_RX_BLOCKSIZE_ALIGN | > + CC33XX_QUIRK_TX_BLOCKSIZE_ALIGN | > + CC33XX_QUIRK_NO_SCHED_SCAN_WHILE_CONN | > + CC33XX_QUIRK_TX_PAD_LAST_FRAME | > + CC33XX_QUIRK_DUAL_PROBE_TMPL; > + > + if (cc->if_ops->get_max_transaction_len) > + cc->max_transaction_len =3D > + cc->if_ops->get_max_transaction_len(cc->dev); > + else > + cc->max_transaction_len =3D 0; > + > + return 0; > +} > + > +static int read_version_info(struct cc33xx *cc) > +{ > + int ret; > + > + ret =3D cc33xx_acx_init_get_fw_versions(cc); > + if (ret < 0) { > + dev_err(cc->dev, "Get FW version FAILED!\n"); > + return ret; > + } > + > + cc33xx_debug(cc->dev, DEBUG_BOOT, "Wireless firmware version %u.%u.%u.%= u\n", > + cc->fw_ver.major_version, > + cc->fw_ver.minor_version, > + cc->fw_ver.api_version, > + cc->fw_ver.build_version); > + > + cc33xx_debug(cc->dev, DEBUG_BOOT, "Wireless PHY version %u.%u.%u.%u.%u.= %u\n", > + cc->fw_ver.phy_version[5], > + cc->fw_ver.phy_version[4], > + cc->fw_ver.phy_version[3], > + cc->fw_ver.phy_version[2], > + cc->fw_ver.phy_version[1], > + cc->fw_ver.phy_version[0]); > + > + return 0; > +} > + > +static int cc33xx_init(struct cc33xx *cc) > +{ > + struct platform_device *pdev =3D cc->pdev; > + struct cc33xx_platdev_data *pdev_data =3D dev_get_platdata(&pdev->dev); > + int ret; > + > + ret =3D cc33xx_setup(cc); > + if (ret < 0) > + return ret; > + > + BUILD_BUG_ON(CC33XX_NUM_TX_DESCRIPTORS > CC33XX_MAX_TX_DESCRIPTORS); > + > + /* adjust some runtime configuration parameters */ > + cc33xx_adjust_conf(cc); > + > + cc->if_ops =3D pdev_data->if_ops; > + cc->if_ops->set_irq_handler(cc->dev, irq_wrapper); > + > + cc33xx_power_off(cc); > + > + setup_wake_irq(cc); > + > + ret =3D cc33xx_init_fw(cc); > + if (ret < 0) { > + dev_err(cc->dev, "FW download failed\n"); > + cc33xx_power_off(cc); > + goto out_irq; > + } > + > + ret =3D cc33xx_identify_chip(cc); > + if (ret < 0) > + goto out_irq; > + > + ret =3D read_version_info(cc); > + if (ret < 0) > + goto out_irq; > + > + ret =3D cc33xx_init_ieee80211(cc); > + if (ret) > + goto out_irq; > + > + ret =3D cc33xx_register_hw(cc); > + if (ret) > + goto out_irq; > + > + cc->initialized =3D true; > + > + cc33xx_debug(cc->dev, DEBUG_CC33XX, "%s complete\n", __func__); > + return 0; > + > +out_irq: > + if (cc->wakeirq >=3D 0) > + dev_pm_clear_wake_irq(cc->dev); > + device_init_wakeup(cc->dev, false); > + > + return ret; > +} > + > +static int cc33xx_load_ini_bin_file(struct device *dev, > + struct cc33xx_conf_file *conf, > + const char *file) > +{ > + struct cc33xx_conf_file *conf_file; > + const struct firmware *fw; > + int ret; > + > + ret =3D request_firmware(&fw, file, dev); > + if (ret < 0) { > + dev_err(dev, "could not get configuration binary %s: %d\n", > + file, ret); > + return ret; > + } > + > + if (fw->size !=3D CC33X_CONF_SIZE) { > + dev_err(dev, "%s configuration binary size is wrong, expected %zu got = %zu\n", > + file, CC33X_CONF_SIZE, > + fw->size); > + ret =3D -EINVAL; > + goto out_release; > + } > + > + conf_file =3D (struct cc33xx_conf_file *)fw->data; > + > + if (conf_file->header.magic !=3D cpu_to_le32(CC33XX_CONF_MAGIC)) { > + dev_err(dev, "conf file magic number mismatch, expected 0x%0x got 0x%0= x\n", > + CC33XX_CONF_MAGIC, conf_file->header.magic); > + ret =3D -EINVAL; > + goto out_release; > + } > + > + memcpy(conf, conf_file, sizeof(*conf)); > + > +out_release: > + release_firmware(fw); > + return ret; > +} > + > +static int cc33xx_ini_bin_init(struct cc33xx *cc, struct device *dev) > +{ > + struct platform_device *pdev =3D cc->pdev; > + struct cc33xx_platdev_data *pdata =3D dev_get_platdata(&pdev->dev); > + > + if (cc33xx_load_ini_bin_file(dev, &cc->conf, > + pdata->family->cfg_name) < 0) > + dev_warn(cc->dev, "falling back to default config\n"); > + > + return 0; > +} > + > +static int cc33xx_setup(struct cc33xx *cc) > +{ > + int ret; > + > + BUILD_BUG_ON(CC33XX_MAX_AP_STATIONS > CC33XX_MAX_LINKS); > + > + ret =3D cc33xx_ini_bin_init(cc, cc->dev); > + if (ret < 0) > + return ret; > + > + if (cc->conf.host_conf.ht.mode =3D=3D HT_MODE_DEFAULT) { > + cc33xx_set_ht_cap(cc, NL80211_BAND_2GHZ, > + &cc33xx_siso40_ht_cap_2ghz); > + > + /* 5Ghz is always wide */ > + cc33xx_set_ht_cap(cc, NL80211_BAND_5GHZ, > + &cc33xx_siso40_ht_cap_5ghz); > + } else if (cc->conf.host_conf.ht.mode =3D=3D HT_MODE_WIDE) { > + cc33xx_set_ht_cap(cc, NL80211_BAND_2GHZ, > + &cc33xx_siso40_ht_cap_2ghz); > + cc33xx_set_ht_cap(cc, NL80211_BAND_5GHZ, > + &cc33xx_siso40_ht_cap_5ghz); > + } else if (cc->conf.host_conf.ht.mode =3D=3D HT_MODE_SISO20) { > + cc33xx_set_ht_cap(cc, NL80211_BAND_2GHZ, &cc33xx_siso20_ht_cap); > + cc33xx_set_ht_cap(cc, NL80211_BAND_5GHZ, &cc33xx_siso20_ht_cap); > + } > + > + cc->event_mask =3D BSS_LOSS_EVENT_ID | SCAN_COMPLETE_EVENT_ID | > + RADAR_DETECTED_EVENT_ID | RSSI_SNR_TRIGGER_0_EVENT_ID | > + PERIODIC_SCAN_COMPLETE_EVENT_ID | > + PERIODIC_SCAN_REPORT_EVENT_ID | DUMMY_PACKET_EVENT_ID | > + PEER_REMOVE_COMPLETE_EVENT_ID | > + BA_SESSION_RX_CONSTRAINT_EVENT_ID | > + REMAIN_ON_CHANNEL_COMPLETE_EVENT_ID | > + CHANNEL_SWITCH_COMPLETE_EVENT_ID | > + DFS_CHANNELS_CONFIG_COMPLETE_EVENT | > + SMART_CONFIG_SYNC_EVENT_ID | INACTIVE_STA_EVENT_ID | > + SMART_CONFIG_DECODE_EVENT_ID | TIME_SYNC_EVENT_ID | > + FW_LOGGER_INDICATION | RX_BA_WIN_SIZE_CHANGE_EVENT_ID; > + > + cc->ap_event_mask =3D MAX_TX_FAILURE_EVENT_ID; > + > + return 0; > +} > + > +static int cc33xx_probe(struct platform_device *pdev) > +{ > + struct cc33xx *cc; > + struct ieee80211_hw *hw; > + struct cc33xx_platdev_data *pdev_data =3D dev_get_platdata(&pdev->dev); > + int ret; > + > + if (!pdev_data) { > + dev_err(&pdev->dev, "can't access platform data\n"); > + return -EINVAL; > + } > + > + hw =3D cc33xx_alloc_hw(); > + if (!hw) { > + dev_err(&pdev->dev, "can't allocate hw\n"); > + return -ENOMEM; > + } > + > + cc =3D hw->priv; > + cc->dev =3D &pdev->dev; > + cc->pdev =3D pdev; > + platform_set_drvdata(pdev, cc); > + > + ret =3D cc33xx_init(cc); > + if (ret < 0) { > + dev_err(cc->dev, "Init failed %d\n", ret); > + cc33xx_free_hw(cc); > + } > + > + return ret; > +} > + > +static void cc33xx_remove(struct platform_device *pdev) > +{ > + struct cc33xx *cc =3D platform_get_drvdata(pdev); > + > + set_bit(CC33XX_FLAG_DRIVER_REMOVED, &cc->flags); > + > + cc->pdev->dev.driver->pm =3D NULL; > + > + if (!cc->initialized) > + goto out; > + > + if (cc->wakeirq >=3D 0) { > + dev_pm_clear_wake_irq(cc->dev); > + cc->wakeirq =3D -ENODEV; > + } > + > + device_init_wakeup(cc->dev, false); > + cc33xx_unregister_hw(cc); > + cc33xx_turn_off(cc); > + > +out: > + cc33xx_free_hw(cc); > +} > + > +static const struct platform_device_id cc33xx_id_table[] =3D { > + { "cc33xx", 0 }, Please make this: { .name =3D "cc33xx" }, > + { } s/ / / > +}; > +MODULE_DEVICE_TABLE(platform, cc33xx_id_table); > + > +static struct platform_driver cc33xx_driver =3D { > + .probe =3D cc33xx_probe, > + .remove =3D cc33xx_remove, > + .id_table =3D cc33xx_id_table, > + .driver =3D { > + .name =3D "cc33xx", > + } > +}; > + > +module_platform_driver(cc33xx_driver); Usually don't put an empty line between the platform_driver and module_platform_driver(). > +module_param_named(debug_level, cc33xx_debug_level, uint, 0600); > +MODULE_PARM_DESC(debug_level, "cc33xx debugging level"); > + > +module_param(no_recovery, int, 0600); > +MODULE_PARM_DESC(no_recovery, "Prevent HW recovery. FW will remain stuck= =2E"); > + > +MODULE_LICENSE("GPL"); > +MODULE_DESCRIPTION("Texas Instruments CC33xx WLAN driver"); > +MODULE_AUTHOR("Michael Nemanov "); > +MODULE_AUTHOR("Sabeeh Khan "); > + > +MODULE_FIRMWARE(SECOND_LOADER_NAME); > +MODULE_FIRMWARE(FW_NAME); > --=20 > 2.34.1 >=20 --fctgpn7wf5qhqrvl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmsRMpIACgkQj4D7WH0S /k6+MwgAqEuBhAAt/rZw6dPTDgOEFh8b73DLi6F4zuxLMqH34FvFKUoCyK1l8eJq 1qAJwPew/4X/cL0DffEb0icebY6eT2U0q7JFNldPH5Swrn6Zw/4nR+otcUYcM2Mj EaELaYspvPYTAjk163WvLY2jruLH37zsDhWmQ8mBBQQ2ygY4M39tcRqqwUF1qL/r EdQvKvXlYzD3rW+oG9j3ccqLL5WpHrvs1wDduPjDwyuFg8oCqHNMJj1TbSWjqOxi tdFG04c1hX89QnQ4xS/7mf4tpePtmD2esZuQBXeQMryXcAwFplQCsW5BejEzJh15 Y9yoA/uOyNLLC6qJ7lHQIUPRZQk3cw== =6/PK -----END PGP SIGNATURE----- --fctgpn7wf5qhqrvl--