From patchwork Thu Sep 19 13:52:38 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: 11152429 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5439216B1 for ; Thu, 19 Sep 2019 13:53:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 16E1421D7A for ; Thu, 19 Sep 2019 13:53:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="afhyTjzh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403932AbfISNxY (ORCPT ); Thu, 19 Sep 2019 09:53:24 -0400 Received: from mail-eopbgr800072.outbound.protection.outlook.com ([40.107.80.72]:49376 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2403856AbfISNwz (ORCPT ); Thu, 19 Sep 2019 09:52:55 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FY8KW7w4PqDohUvQUb+KGhh4CLBGTq0nhnmGG8DBzrqRhMMzTYiHQI0p4QKnGKkgLLvtjzeNPWNdam15tYks38FlLuBkXItbvQE593slvud2q04RY3dP8Qhf9jGLJHMIkKfCnvoFexfxpMeUTbVBDt6C2N77psXBWfQI2amDEI+XhwrOGNT4T/ffsjs77y82iF7w0m+AGlaO1GAR7vEXhaiVRNQbKKY6Q5yYZq9ZQPoKyI6JCILnrRmxoWmgj4bErtAlmFCdx3Vedlfo//BG8LgJmdCWgxDT49ZjKadCdTC0mS9GRRjngza4QeRh6gxN3WJ/J4rgyj5Mk3S2OjhD1g== 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=ADLsubPBbtsWnV3O8I6GuH+sF2YQUY+tSKwySNQ3N6A=; b=BaU/wgcIBcS5Cle/cuGDQ0YHp5kDJEe2X+aSDFweTcU2UaHdn6eCA4HuoMIQXWxRBIbAPuMP7LgST05FzwTLp+yWYWO77YtVs/6kDbgwlN1vZUDvbqHvnBK17W/1x96MjIgPzbRPn3ERmtc2B2avgLOlcDYjna6+ifDaqUVa0yl7mqaNe7ssjWSz4tSxbLjjomn9vsbvmFdgORHNDQszUU8RhPmJEcYiNYMag1oNNRyRZnNnfev8K/3tCNJ25MkOYgkFoyKyl5NTd9r/TS5Ko7nMiCJmhX/oae+ch/HqoWp5SCd48gr83qubGLhdYQNw64lmYZ4FUdyqnOuOrPOPDw== 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=ADLsubPBbtsWnV3O8I6GuH+sF2YQUY+tSKwySNQ3N6A=; b=afhyTjzhGvQryqDWeXwkgz+teEdxs3AEdLjVpZnzUupsBM+EwZgvgqR2nSehPes+1Yz1nSkOyqYksxMT3LHNA7xB+X//h7811cryhLXXT5D0QLorkOAbuPXaqNznS5Xt55l3AYs5qDUnhqthmrsinEwMswkAM0qWbrZ+kCh0LxA= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (20.179.149.217) by MN2PR11MB3871.namprd11.prod.outlook.com (10.255.180.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.18; Thu, 19 Sep 2019 13:52:39 +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 13:52:39 +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 v2 15/20] staging: wfx: add debug files and trace debug events Thread-Topic: [PATCH v2 15/20] staging: wfx: add debug files and trace debug events Thread-Index: AQHVbvF/mjGL+48vvEqaljR3PdJT+Q== Date: Thu, 19 Sep 2019 13:52:38 +0000 Message-ID: <20190919135220.30663-16-Jerome.Pouiller@silabs.com> References: <20190919135220.30663-1-Jerome.Pouiller@silabs.com> In-Reply-To: <20190919135220.30663-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: 062491fe-9d1b-4377-f3a9-08d73d08a2e3 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:MN2PR11MB3871; x-ms-traffictypediagnostic: MN2PR11MB3871: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:327; x-forefront-prvs: 016572D96D x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(396003)(376002)(366004)(346002)(39850400004)(199004)(189003)(305945005)(2906002)(71190400001)(186003)(71200400001)(7736002)(91956017)(1076003)(66574012)(25786009)(66476007)(86362001)(66446008)(64756008)(66556008)(6506007)(3846002)(36756003)(2501003)(14444005)(486006)(11346002)(256004)(2616005)(476003)(76116006)(26005)(66946007)(446003)(76176011)(14454004)(8936002)(99286004)(66066001)(478600001)(81166006)(107886003)(5660300002)(102836004)(6116002)(81156014)(8676002)(316002)(4326008)(54906003)(6486002)(110136005)(6512007)(6436002);DIR:OUT;SFP:1101;SCL:1;SRVR:MN2PR11MB3871;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: 73IMGYJ7PLhymEbFMdOmhJA7oNKpBNmJ7OAyVyrtaDiNL2J1JRtiMT/HfDk+pt5whtpNPdcJL9FVIDkh3vq4hWAIgQADdbdyD7aMBf34JLZFM43uG5KZH6X3OPG8UtNRAMwV3WVDYB1Q8dPtoQd7Ls7tWxb4RjjKb7tJTmYFAt1jWBopZKDSQo/wes7G7imb9F1Pkh3qAMi3UpyuWTlUk3t7r8V8yvdy8xiagDiylAp9qv3DkP1gOXoHlEjiytoM6qqsX3G2eU7dQwOEne5Sk0Le5a2q/MXOiQ7N0S8SGiMuBYip/jAxi68kFwx8uwNkM9DtJ9HD8n1AHnpST05HXwsSaCHX2hH5TmZznUwe34Rn9jQc5GUbLSd4OlrmiH2gnO1n89GuDhrxGm8pGF+PLP4f0ij0bYPZM3aYLweZfiI= Content-ID: MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 062491fe-9d1b-4377-f3a9-08d73d08a2e3 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Sep 2019 13:52:38.6751 (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: AvucDTNrRju/I7ZZHNpWlMbwt3q1r7ZycFjwK0Zqz+tPdUuvcVuT3OTcL4PSS0M5B2YZEKl5iPGKmITxzbtEUw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3871 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Jérôme Pouiller Add traces when debug events happen and allow to ask internal information to chip. These features work independently from mac80211. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/debug.c | 105 +++++++++++++++++++++++++++++++++++ drivers/staging/wfx/hif_rx.c | 80 ++++++++++++++++++++++++++ drivers/staging/wfx/main.c | 2 + drivers/staging/wfx/wfx.h | 16 ++++++ 4 files changed, 203 insertions(+) diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c index 0619c7d1cf79..1e23bb5bde3e 100644 --- a/drivers/staging/wfx/debug.c +++ b/drivers/staging/wfx/debug.c @@ -6,11 +6,13 @@ * Copyright (c) 2010, ST-Ericsson */ #include +#include #include #include "debug.h" #include "wfx.h" #include "main.h" +#include "hif_tx_mib.h" #define CREATE_TRACE_POINTS #include "traces.h" @@ -55,6 +57,107 @@ const char *get_reg_name(unsigned long id) return get_symbol(id, wfx_reg_print_map); } +static int wfx_counters_show(struct seq_file *seq, void *v) +{ + int ret; + struct wfx_dev *wdev = seq->private; + struct hif_mib_extended_count_table counters; + + ret = hif_get_counters_table(wdev, &counters); + if (ret < 0) + return ret; + if (ret > 0) + return -EIO; + +#define PUT_COUNTER(name) \ + seq_printf(seq, "%24s %d\n", #name ":", le32_to_cpu(counters.count_##name)) + + PUT_COUNTER(tx_packets); + PUT_COUNTER(tx_multicast_frames); + PUT_COUNTER(tx_frames_success); + PUT_COUNTER(tx_frame_failures); + PUT_COUNTER(tx_frames_retried); + PUT_COUNTER(tx_frames_multi_retried); + + PUT_COUNTER(rts_success); + PUT_COUNTER(rts_failures); + PUT_COUNTER(ack_failures); + + PUT_COUNTER(rx_packets); + PUT_COUNTER(rx_frames_success); + PUT_COUNTER(rx_packet_errors); + PUT_COUNTER(plcp_errors); + PUT_COUNTER(fcs_errors); + PUT_COUNTER(rx_decryption_failures); + PUT_COUNTER(rx_mic_failures); + PUT_COUNTER(rx_no_key_failures); + PUT_COUNTER(rx_frame_duplicates); + PUT_COUNTER(rx_multicast_frames); + PUT_COUNTER(rx_cmacicv_errors); + PUT_COUNTER(rx_cmac_replays); + PUT_COUNTER(rx_mgmt_ccmp_replays); + + PUT_COUNTER(rx_beacon); + PUT_COUNTER(miss_beacon); + +#undef PUT_COUNTER + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(wfx_counters); + +static const char * const channel_names[] = { + [0] = "1M", + [1] = "2M", + [2] = "5.5M", + [3] = "11M", + /* Entries 4 and 5 does not exist */ + [6] = "6M", + [7] = "9M", + [8] = "12M", + [9] = "18M", + [10] = "24M", + [11] = "36M", + [12] = "48M", + [13] = "54M", + [14] = "MCS0", + [15] = "MCS1", + [16] = "MCS2", + [17] = "MCS3", + [18] = "MCS4", + [19] = "MCS5", + [20] = "MCS6", + [21] = "MCS7", +}; + +static int wfx_rx_stats_show(struct seq_file *seq, void *v) +{ + struct wfx_dev *wdev = seq->private; + struct hif_rx_stats *st = &wdev->rx_stats; + int i; + + mutex_lock(&wdev->rx_stats_lock); + seq_printf(seq, "Timestamp: %dus\n", st->date); + seq_printf(seq, "Low power clock: frequency %uHz, external %s\n", + st->pwr_clk_freq, + st->is_ext_pwr_clk ? "yes" : "no"); + seq_printf(seq, "Num. of frames: %d, PER (x10e4): %d, Throughput: %dKbps/s\n", + st->nb_rx_frame, st->per_total, st->throughput); + seq_puts(seq, " Num. of PER RSSI SNR CFO\n"); + seq_puts(seq, " frames (x10e4) (dBm) (dB) (kHz)\n"); + for (i = 0; i < ARRAY_SIZE(channel_names); i++) { + if (channel_names[i]) + seq_printf(seq, "%5s %8d %8d %8d %8d %8d\n", + channel_names[i], st->nb_rx_by_rate[i], + st->per[i], st->rssi[i] / 100, + st->snr[i] / 100, st->cfo[i]); + } + mutex_unlock(&wdev->rx_stats_lock); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(wfx_rx_stats); + static ssize_t wfx_send_pds_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { @@ -190,6 +293,8 @@ int wfx_debug_init(struct wfx_dev *wdev) struct dentry *d; d = debugfs_create_dir("wfx", wdev->hw->wiphy->debugfsdir); + debugfs_create_file("counters", 0444, d, wdev, &wfx_counters_fops); + debugfs_create_file("rx_stats", 0444, d, wdev, &wfx_rx_stats_fops); debugfs_create_file("send_pds", 0200, d, wdev, &wfx_send_pds_fops); debugfs_create_file("burn_slk_key", 0200, d, wdev, &wfx_burn_slk_key_fops); debugfs_create_file("send_hif_msg", 0600, d, wdev, &wfx_send_hif_msg_fops); diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index 6b9683d69a3f..c93bae1b6acf 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -94,13 +94,93 @@ static int hif_keys_indication(struct wfx_dev *wdev, struct hif_msg *hif, void * return 0; } +static int hif_join_complete_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +{ + struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); + + WARN_ON(!wvif); + dev_warn(wdev->dev, "unattended JoinCompleteInd\n"); + + return 0; +} + +static int hif_error_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +{ + struct hif_ind_error *body = buf; + u8 *pRollback = (u8 *) body->data; + u32 *pStatus = (u32 *) body->data; + + switch (body->type) { + case HIF_ERROR_FIRMWARE_ROLLBACK: + dev_err(wdev->dev, "asynchronous error: firmware rollback error %d\n", *pRollback); + break; + case HIF_ERROR_FIRMWARE_DEBUG_ENABLED: + dev_err(wdev->dev, "asynchronous error: firmware debug feature enabled\n"); + break; + case HIF_ERROR_OUTDATED_SESSION_KEY: + dev_err(wdev->dev, "asynchronous error: secure link outdated key: %#.8x\n", *pStatus); + break; + case HIF_ERROR_INVALID_SESSION_KEY: + dev_err(wdev->dev, "asynchronous error: invalid session key\n"); + break; + case HIF_ERROR_OOR_VOLTAGE: + dev_err(wdev->dev, "asynchronous error: out-of-range overvoltage: %#.8x\n", *pStatus); + break; + case HIF_ERROR_PDS_VERSION: + dev_err(wdev->dev, "asynchronous error: wrong PDS payload or version: %#.8x\n", *pStatus); + break; + default: + dev_err(wdev->dev, "asynchronous error: unknown (%d)\n", body->type); + break; + } + return 0; +} + +static int hif_generic_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +{ + struct hif_ind_generic *body = buf; + + switch (body->indication_type) { + case HIF_GENERIC_INDICATION_TYPE_RAW: + return 0; + case HIF_GENERIC_INDICATION_TYPE_STRING: + dev_info(wdev->dev, "firmware says: %s\n", (char *) body->indication_data.raw_data); + return 0; + case HIF_GENERIC_INDICATION_TYPE_RX_STATS: + mutex_lock(&wdev->rx_stats_lock); + // Older firmware send a generic indication beside RxStats + if (!wfx_api_older_than(wdev, 1, 4)) + dev_info(wdev->dev, "Rx test ongoing. Temperature: %d°C\n", body->indication_data.rx_stats.current_temp); + memcpy(&wdev->rx_stats, &body->indication_data.rx_stats, sizeof(wdev->rx_stats)); + mutex_unlock(&wdev->rx_stats_lock); + return 0; + default: + dev_err(wdev->dev, "generic_indication: unknown indication type: %#.8x\n", body->indication_type); + return -EIO; + } +} + +static int hif_exception_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +{ + size_t len = hif->len - 4; // drop header + dev_err(wdev->dev, "firmware exception\n"); + print_hex_dump_bytes("Dump: ", DUMP_PREFIX_NONE, buf, len); + wdev->chip_frozen = 1; + + return -1; +} + static const struct { int msg_id; int (*handler)(struct wfx_dev *wdev, struct hif_msg *hif, void *buf); } hif_handlers[] = { { HIF_IND_ID_STARTUP, hif_startup_indication }, { HIF_IND_ID_WAKEUP, hif_wakeup_indication }, + { HIF_IND_ID_JOIN_COMPLETE, hif_join_complete_indication }, { HIF_IND_ID_SL_EXCHANGE_PUB_KEYS, hif_keys_indication }, + { HIF_IND_ID_GENERIC, hif_generic_indication }, + { HIF_IND_ID_ERROR, hif_error_indication }, + { HIF_IND_ID_EXCEPTION, hif_exception_indication }, }; void wfx_handle_rx(struct wfx_dev *wdev, struct sk_buff *skb) diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index 5b04ea5f4353..2e71f446d4d4 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -212,6 +212,7 @@ struct wfx_dev *wfx_init_common(struct device *dev, wdev->pdata.gpio_wakeup = wfx_get_gpio(dev, gpio_wakeup, "wakeup"); wfx_fill_sl_key(dev, &wdev->pdata); + mutex_init(&wdev->rx_stats_lock); init_completion(&wdev->firmware_ready); wfx_init_hif_cmd(&wdev->hif_cmd); @@ -220,6 +221,7 @@ struct wfx_dev *wfx_init_common(struct device *dev, void wfx_free_common(struct wfx_dev *wdev) { + mutex_destroy(&wdev->rx_stats_lock); ieee80211_free_hw(wdev->hw); } diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 7adb5bf67e90..49b776a07515 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -38,6 +38,9 @@ struct wfx_dev { int chip_frozen; struct wfx_hif_cmd hif_cmd; + + struct hif_rx_stats rx_stats; + struct mutex rx_stats_lock; }; struct wfx_vif { @@ -46,4 +49,17 @@ struct wfx_vif { int id; }; +static inline struct wfx_vif *wdev_to_wvif(struct wfx_dev *wdev, int vif_id) +{ + if (vif_id >= ARRAY_SIZE(wdev->vif)) { + dev_dbg(wdev->dev, "requesting non-existent vif: %d\n", vif_id); + return NULL; + } + if (!wdev->vif[vif_id]) { + dev_dbg(wdev->dev, "requesting non-allocated vif: %d\n", vif_id); + return NULL; + } + return (struct wfx_vif *) wdev->vif[vif_id]->drv_priv; +} + #endif /* WFX_H */