From patchwork Thu Feb 18 18:34:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zopieux X-Patchwork-Id: 8353501 Return-Path: X-Original-To: patchwork-linux-wpan@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 01863C0553 for ; Thu, 18 Feb 2016 18:50:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 50B8D2039E for ; Thu, 18 Feb 2016 18:50:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B89FD2038D for ; Thu, 18 Feb 2016 18:50:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946859AbcBRSuI (ORCPT ); Thu, 18 Feb 2016 13:50:08 -0500 Received: from r0.smtpout1.alwaysdata.com ([176.31.58.0]:60173 "EHLO r0.smtpout1.alwaysdata.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1946703AbcBRSuH (ORCPT ); Thu, 18 Feb 2016 13:50:07 -0500 X-Greylist: delayed 921 seconds by postgrey-1.27 at vger.kernel.org; Thu, 18 Feb 2016 13:50:07 EST DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=alwaysdata.net; s=zopieux; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Date:Message-ID:Subject:From:Cc:To; bh=XScIqNHM3UYngHp4GW0Wro0ojnnhIJgn/4TcWel+zHg=; b=GsdOWUjB+fbp0W4PFtl2LSKiOV0TG96ymaCVyYT6LP+O+wpwBD2zdDvl9hjOcyfOAkCbPKzzxV6CT77HYCDnZfWSo7CeUgbcpfr6HMHls0Aeze0JmNGrk+/56xIrXwhXhrhtK8gn4kHXf6nbYX7jr0TBEcuH6qyj7tOtlOqbXRE=; Received: from agrenoble-651-1-484-168.w90-42.abo.wanadoo.fr ([90.42.180.168] helo=[192.168.1.19]) by smtpout1.roubaix1.alwaysdata.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84) (envelope-from ) id 1aWTPR-0003XB-8I; Thu, 18 Feb 2016 19:34:37 +0100 To: linux-wpan@vger.kernel.org Cc: netdev@vger.kernel.org, Alan Ott , Alexander Aring From: zopieux Subject: [PATCH] mrf24j40: fix security-enabled processing on inbound frames Message-ID: <56C60EBA.2070707@zopieux.com> Date: Thu, 18 Feb 2016 19:34:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 X-alwaysdata-ID: 127241873 Sender: linux-wpan-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix the MRF24J40 handling of security-enabled frames so it does not block upon receiving such frames. Signed-off-by: Alexander Aring Reported-by: Alexandre Macabies Tested-by: Alexandre Macabies --- When receiving a security-enabled IEEE 802.15.4 frame, the MRF24J40 triggers a SECIF interrupt that needs to be handled for RX processing to keep functioning properly. This patch enables the SECIF interrupt and makes the MRF ignores all hardware processing of security-enabled frames, that is handled by the ieee802154 stack instead. --- drivers/net/ieee802154/mrf24j40.c | 11 ++++++++++- include/linux/ieee802154.h | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/net/ieee802154/mrf24j40.c b/drivers/net/ieee802154/mrf24j40.c index 4cdf516..fdfdcec 100644 --- a/drivers/net/ieee802154/mrf24j40.c +++ b/drivers/net/ieee802154/mrf24j40.c @@ -61,6 +61,7 @@ #define REG_TXBCON0 0x1A #define REG_TXNCON 0x1B /* Transmit Normal FIFO Control */ #define BIT_TXNTRIG BIT(0) +#define BIT_TXNSECEN BIT(1) #define BIT_TXNACKREQ BIT(2) #define REG_TXG1CON 0x1C @@ -85,10 +86,12 @@ #define REG_INTSTAT 0x31 /* Interrupt Status */ #define BIT_TXNIF BIT(0) #define BIT_RXIF BIT(3) +#define BIT_SECIF BIT(4) #define REG_INTCON 0x32 /* Interrupt Control */ #define BIT_TXNIE BIT(0) #define BIT_RXIE BIT(3) +#define BIT_SECIE BIT(4) #define REG_GPIO 0x33 /* GPIO */ #define REG_TRISGPIO 0x34 /* GPIO direction */ @@ -547,6 +550,9 @@ static void write_tx_buf_complete(void *context) u8 val = BIT_TXNTRIG; int ret; + if (ieee802154_is_secen(fc)) + val |= BIT_TXNSECEN; + if (ieee802154_is_ackreq(fc)) val |= BIT_TXNACKREQ; @@ -615,7 +621,7 @@ static int mrf24j40_start(struct ieee802154_hw *hw) /* Clear TXNIE and RXIE. Enable interrupts */ return regmap_update_bits(devrec->regmap_short, REG_INTCON, - BIT_TXNIE | BIT_RXIE, 0); + BIT_TXNIE | BIT_RXIE | BIT_SECIE, 0); } static void mrf24j40_stop(struct ieee802154_hw *hw) @@ -1024,6 +1030,9 @@ static void mrf24j40_intstat_complete(void *context) enable_irq(devrec->spi->irq); + if (intstat & BIT_SECIF) + regmap_write_async(devrec->regmap_short, REG_SECCON0, 0x80); + /* Check for TX complete */ if (intstat & BIT_TXNIF) ieee802154_xmit_complete(devrec->hw, devrec->tx_skb, false); diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h index d3e4156..334fb1e 100644 --- a/include/linux/ieee802154.h +++ b/include/linux/ieee802154.h @@ -218,6 +218,7 @@ enum { /* frame control handling */ #define IEEE802154_FCTL_FTYPE 0x0003 #define IEEE802154_FCTL_ACKREQ 0x0020 +#define IEEE802154_FCTL_SECEN 0x0004 #define IEEE802154_FCTL_INTRA_PAN 0x0040 #define IEEE802154_FTYPE_DATA 0x0001 @@ -233,6 +234,15 @@ static inline int ieee802154_is_data(__le16 fc) } /** + * ieee802154_is_secen - check if Security bit is set + * @fc: frame control bytes in little-endian byteorder + */ +static inline bool ieee802154_is_secen(__le16 fc) +{ + return fc & cpu_to_le16(IEEE802154_FCTL_SECEN); +} + +/** * ieee802154_is_ackreq - check if acknowledgment request bit is set * @fc: frame control bytes in little-endian byteorder */