From patchwork Thu Sep 19 14:25:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 1164695 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=silabs.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="lOqV837s"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46YzgR4q0bz9sPv for ; Fri, 20 Sep 2019 00:26:43 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389352AbfISO0j (ORCPT ); Thu, 19 Sep 2019 10:26:39 -0400 Received: from mail-eopbgr780041.outbound.protection.outlook.com ([40.107.78.41]:35720 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2390669AbfISOZz (ORCPT ); Thu, 19 Sep 2019 10:25:55 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iEGxBsLUQtjtXQHyG0b2TWuvTXuLvW8ZicwKy9v0MWFtFaTPMPK7fWfoazPxY88hCSEmKsnRGzO6TYkCkFgzCCvoRPBOZhYX9r4m2nXWPYUp5SE0eyGrX2FhAiZjBakHDV6C4GjRLfsG+gA+TtahHcICgmtpt4dUpzz9C+kBBI7EZU/i5x8qleCLWRdQqlQS2e9ZnJ/ASYYYnrr4THBWKfaxi18lBkiv14zVXfjdKd5LU2smVnuZJViTc3vvvd1ezqjBF2mWz//7m4eDpsHAOTpblZekTqg6PkgwxBMBsn7+LQmsj0z3c5dkUXQtqu0a1LzA7MhPPD9RG+Cx+QwLng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RzgzJ2vGlgg9gz0VCTcZn3NVg+4ji2QAhdRHuUkOvS0=; b=KGnRRNYNNciOxa1jDycr1VUa1YeIGGb7w9npUrRTaMOIuHdu6aY9U9TsxUcCi+Kg7wgnli+U5yKsiHeWUsjWyiX6dIkaAHCd6qAtOSLgj8OtZHjxKQvZ/7mJ2Lu6bZypKdDhTkbXy3jAU15/IcBsh3YS8V1abInUn9x3D+PpSSgpSHIZc6HYv2kNYlrnKe7WZkd0QrIfbX8EbnoqYlT8qr7E6PgZ2PxHZ9D3tClTAYyQlPPWGA57nEACOGtrGNTguTBzFm02lg2GsO/N/xV+5SOFUTqJFz0H8Oww6sz0i3XGd/hnK1yCFO2mtSaVO9ZNl8Ld2QnsWQlhI08tNdsvZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RzgzJ2vGlgg9gz0VCTcZn3NVg+4ji2QAhdRHuUkOvS0=; b=lOqV837stId7phZN8ev/UX/XqaDa1R53LaBms3abftWmflchLtsvXBdfLXB9sOWFmKSBdCBDNgX0Lb+5Lb0K/LzVk+jJtnvkhqWFWUNadehOPYDkebxHy3pVS/xh2vn869CpTwwEs8bEBFsrJ5M9CwwiqVYuivA5KuE2l8LRS3Y= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (20.179.149.217) by MN2PR11MB4207.namprd11.prod.outlook.com (52.135.37.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.24; Thu, 19 Sep 2019 14:25:43 +0000 Received: from MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::45dc:e073:4446:4bf8]) by MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::45dc:e073:4446:4bf8%3]) with mapi id 15.20.2263.023; Thu, 19 Sep 2019 14:25:43 +0000 From: Jerome Pouiller To: "devel@driverdev.osuosl.org" , "linux-wireless@vger.kernel.org" CC: "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , David Le Goff , Jerome Pouiller Subject: [PATCH v3 10/20] staging: wfx: instantiate mac80211 data Thread-Topic: [PATCH v3 10/20] staging: wfx: instantiate mac80211 data Thread-Index: AQHVbvYdMkVtDsCfRUW0cHX4DtwO7g== Date: Thu, 19 Sep 2019 14:25:41 +0000 Message-ID: <20190919142527.31797-11-Jerome.Pouiller@silabs.com> References: <20190919142527.31797-1-Jerome.Pouiller@silabs.com> In-Reply-To: <20190919142527.31797-1-Jerome.Pouiller@silabs.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jerome.Pouiller@silabs.com; x-originating-ip: [37.71.187.125] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f2f42f33-2db7-4c2f-0fdf-08d73d0d40fa x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4207; x-ms-traffictypediagnostic: MN2PR11MB4207: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:475; x-forefront-prvs: 016572D96D x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(346002)(376002)(39850400004)(366004)(396003)(136003)(199004)(189003)(2501003)(71200400001)(71190400001)(99286004)(4326008)(478600001)(25786009)(6512007)(107886003)(3846002)(6116002)(14454004)(256004)(6486002)(2906002)(1076003)(86362001)(6436002)(2616005)(476003)(26005)(316002)(446003)(36756003)(8676002)(81166006)(81156014)(11346002)(54906003)(110136005)(8936002)(102836004)(186003)(5660300002)(7736002)(305945005)(91956017)(76176011)(66066001)(66946007)(6506007)(486006)(76116006)(66476007)(66446008)(64756008)(66556008); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4207; H:MN2PR11MB4063.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: silabs.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: YpCqFih3KuuvQ/4Es3z3TMVm+8g4R1cSY/mPix+FqJmTxXyQj8gtyP7kxE3dpXFzpEq6pwGSm3Qwzxk08QMJbxRlti1Bo9H53CF8DCYbI4iXzWb1D27iwruJoHTEhR/NxaDn6v2WQS3ViNxhDl0xK+AYHlHtpkvMy0AWKAWSIiw1VoYcEsHjxSWj3UpxxRMLIBsSYu8J/4dqNo/VGZu6Txc/MDHuOVet7+nQPMDcFQ31y4XL/7HLKN/WR4avhZZI+lNBVevp+wTmKxEygwaKqP/KkKeia4ej6dJq03O90a3cBqehViksT17BHo21KYqCOa02HSb7l+yHLMZqtD2XiXuY31cXbPCWMhLOCa0tvcrv3JmRXBQokn0D1BQHWS/YnpK3DJ/lfJo65RuXviUD9he7i7/x8O4QFyq0K1tfUIk= Content-ID: <5D18ACAE103AE844913C7460844B0F30@namprd11.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2f42f33-2db7-4c2f-0fdf-08d73d0d40fa X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Sep 2019 14:25:41.8860 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: MWm2iPckf4AzXQOHThPYGIYUqXc6ciTwLQOmi5R8wxMRwjIqbR/lwa3enQ3Fxfc3xxYla8j/PzIS5C5ENZC+GQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4207 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller Allocate a struct ieee80211_hw but do not yet register it. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/Makefile | 1 + drivers/staging/wfx/debug.c | 12 ++++++++++ drivers/staging/wfx/debug.h | 15 ++++++++++++ drivers/staging/wfx/main.c | 41 ++++++++++++++++++++++++++++++-- drivers/staging/wfx/sta.c | 46 ++++++++++++++++++++++++++++++++++++ drivers/staging/wfx/sta.h | 24 +++++++++++++++++++ drivers/staging/wfx/wfx.h | 8 +++++++ 7 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 drivers/staging/wfx/debug.h create mode 100644 drivers/staging/wfx/sta.c create mode 100644 drivers/staging/wfx/sta.h diff --git a/drivers/staging/wfx/Makefile b/drivers/staging/wfx/Makefile index 35670b86c64f..2896a2127c88 100644 --- a/drivers/staging/wfx/Makefile +++ b/drivers/staging/wfx/Makefile @@ -9,6 +9,7 @@ wfx-y := \ fwio.o \ hif_rx.o \ main.o \ + sta.o \ debug.o wfx-$(CONFIG_SPI) += bus_spi.o wfx-$(subst m,y,$(CONFIG_MMC)) += bus_sdio.o diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c index bf44c944640d..f28c94d8de89 100644 --- a/drivers/staging/wfx/debug.c +++ b/drivers/staging/wfx/debug.c @@ -5,6 +5,18 @@ * Copyright (c) 2017-2019, Silicon Laboratories, Inc. * Copyright (c) 2010, ST-Ericsson */ +#include + +#include "wfx.h" #define CREATE_TRACE_POINTS #include "traces.h" + +int wfx_debug_init(struct wfx_dev *wdev) +{ + struct dentry *d; + + d = debugfs_create_dir("wfx", wdev->hw->wiphy->debugfsdir); + + return 0; +} diff --git a/drivers/staging/wfx/debug.h b/drivers/staging/wfx/debug.h new file mode 100644 index 000000000000..8bfba1a9fa20 --- /dev/null +++ b/drivers/staging/wfx/debug.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Debugfs interface. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2011, ST-Ericsson + */ +#ifndef WFX_DEBUG_H +#define WFX_DEBUG_H + +struct wfx_dev; + +int wfx_debug_init(struct wfx_dev *wdev); + +#endif /* WFX_DEBUG_H */ diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index 5e7e7225f068..ca0ca873bd7d 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -25,6 +25,9 @@ #include "hwio.h" #include "bus.h" #include "bh.h" +#include "sta.h" +#include "debug.h" +#include "hif_api_cmd.h" #include "wfx_version.h" MODULE_DESCRIPTION("Silicon Labs 802.11 Wireless LAN driver for WFx"); @@ -36,6 +39,13 @@ static int gpio_wakeup = -2; module_param(gpio_wakeup, int, 0644); MODULE_PARM_DESC(gpio_wakeup, "gpio number for wakeup. -1 for none."); +static const struct ieee80211_ops wfx_ops = { + .start = wfx_start, + .stop = wfx_stop, + .add_interface = wfx_add_interface, + .remove_interface = wfx_remove_interface, +}; + bool wfx_api_older_than(struct wfx_dev *wdev, int major, int minor) { if (wdev->hw_caps.api_version_major < major) @@ -79,11 +89,26 @@ struct wfx_dev *wfx_init_common(struct device *dev, const struct hwbus_ops *hwbus_ops, void *hwbus_priv) { + struct ieee80211_hw *hw; struct wfx_dev *wdev; - wdev = devm_kmalloc(dev, sizeof(*wdev), GFP_KERNEL); - if (!wdev) + hw = ieee80211_alloc_hw(sizeof(struct wfx_dev), &wfx_ops); + if (!hw) return NULL; + + SET_IEEE80211_DEV(hw, dev); + + hw->vif_data_size = sizeof(struct wfx_vif); + hw->sta_data_size = sizeof(struct wfx_sta_priv); + hw->queues = 4; + hw->max_rates = 8; + hw->max_rate_tries = 15; + hw->extra_tx_headroom = sizeof(struct hif_sl_msg_hdr) + sizeof(struct hif_msg) + + sizeof(struct hif_req_tx) + + 4 /* alignment */ + 8 /* TKIP IV */; + + wdev = hw->priv; + wdev->hw = hw; wdev->dev = dev; wdev->hwbus_ops = hwbus_ops; wdev->hwbus_priv = hwbus_priv; @@ -96,6 +121,7 @@ struct wfx_dev *wfx_init_common(struct device *dev, void wfx_free_common(struct wfx_dev *wdev) { + ieee80211_free_hw(wdev->hw); } int wfx_probe(struct wfx_dev *wdev) @@ -127,6 +153,11 @@ int wfx_probe(struct wfx_dev *wdev) wdev->hw_caps.firmware_build, wdev->hw_caps.firmware_label, wdev->hw_caps.api_version_major, wdev->hw_caps.api_version_minor, wdev->keyset, *((u32 *) &wdev->hw_caps.capabilities)); + snprintf(wdev->hw->wiphy->fw_version, sizeof(wdev->hw->wiphy->fw_version), + "%d.%d.%d", + wdev->hw_caps.firmware_major, + wdev->hw_caps.firmware_minor, + wdev->hw_caps.firmware_build); if (wfx_api_older_than(wdev, 1, 0)) { dev_err(wdev->dev, "unsupported firmware API version (expect 1 while firmware returns %d)\n", @@ -150,8 +181,14 @@ int wfx_probe(struct wfx_dev *wdev) dev_info(wdev->dev, "MAC address %d: %pM\n", i, wdev->addresses[i].addr); } + err = wfx_debug_init(wdev); + if (err) + goto err2; + return 0; +err2: + ieee80211_free_hw(wdev->hw); err1: wfx_bh_unregister(wdev); return err; diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c new file mode 100644 index 000000000000..fe3ff6536a87 --- /dev/null +++ b/drivers/staging/wfx/sta.c @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Implementation of mac80211 API. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#include + +#include "sta.h" +#include "wfx.h" + +int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) +{ + int i; + struct wfx_dev *wdev = hw->priv; + struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; + + for (i = 0; i < ARRAY_SIZE(wdev->vif); i++) { + if (!wdev->vif[i]) { + wdev->vif[i] = vif; + wvif->id = i; + break; + } + } + if (i == ARRAY_SIZE(wdev->vif)) + return -EOPNOTSUPP; + wvif->vif = vif; + wvif->wdev = wdev; + + return 0; +} + +void wfx_remove_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif) +{ +} + +int wfx_start(struct ieee80211_hw *hw) +{ + return 0; +} + +void wfx_stop(struct ieee80211_hw *hw) +{ +} diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h new file mode 100644 index 000000000000..f17b4d1511d7 --- /dev/null +++ b/drivers/staging/wfx/sta.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Implementation of mac80211 API. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#ifndef WFX_STA_H +#define WFX_STA_H + +#include + +struct wfx_sta_priv { + int link_id; + int vif_id; +}; + +// mac80211 interface +int wfx_start(struct ieee80211_hw *hw); +void wfx_stop(struct ieee80211_hw *hw); +int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif); +void wfx_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif); + +#endif /* WFX_STA_H */ diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index f5f9a337d828..a7e571e0da30 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -22,6 +22,8 @@ struct hwbus_ops; struct wfx_dev { struct wfx_platform_data pdata; struct device *dev; + struct ieee80211_hw *hw; + struct ieee80211_vif *vif[2]; struct mac_address addresses[2]; const struct hwbus_ops *hwbus_ops; void *hwbus_priv; @@ -32,4 +34,10 @@ struct wfx_dev { struct wfx_hif hif; }; +struct wfx_vif { + struct wfx_dev *wdev; + struct ieee80211_vif *vif; + int id; +}; + #endif /* WFX_H */