From patchwork Sat Jan 31 09:28:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 435112 X-Patchwork-Delegate: nbd@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B37CE1402CF for ; Sat, 31 Jan 2015 20:32:12 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 560A528BF5D; Sat, 31 Jan 2015 10:28:02 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, T_DKIM_INVALID autolearn=no version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id E4DB228756E for ; Sat, 31 Jan 2015 10:27:22 +0100 (CET) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com [209.85.212.171]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Sat, 31 Jan 2015 10:27:15 +0100 (CET) Received: by mail-wi0-f171.google.com with SMTP id l15so7614708wiw.4 for ; Sat, 31 Jan 2015 01:29:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=aEP4IkRKwJYFInINEHtczdeuGy7jyCWaLzJAu9wmgXg=; b=vWHp+vbTjeALvwP4j824DPFWaNh6cqj46ZpvBRU9d/Ske9rTawL2b7xlgQCOlI7WM9 Okosnue+T5rALda+5iS6+QfjASb7GjIYCtyAsdGh7CsdM7F+ObuOKTOw6CqD7ZHU5QA+ /C/cwhkPW5OMa6CRnnpKvt85zF/G9epg9njLCPI9WCI9ihi9QblD7IGya+MTC96/YcKG l+NOYho7+gcyprOehpByP+KCZA00vYxLxOAKlAwrNF5Fv0f/SeRw34maMaV800qra1Zl f6QuzB5Hkphe3GTX3K9Ydz6alb50tOI1ATNs7UES6FpJAQaluHE0rd0xDgXxCw8N5pll E6gg== X-Received: by 10.180.205.142 with SMTP id lg14mr3046671wic.82.1422696583635; Sat, 31 Jan 2015 01:29:43 -0800 (PST) Received: from ?IPv6:2003:63:231f:ff00:a574:a623:8907:1aab? (p20030063231FFF00A574A62389071AAB.dip0.t-ipconnect.de. [2003:63:231f:ff00:a574:a623:8907:1aab]) by mx.google.com with ESMTPSA id hz9sm18476951wjb.17.2015.01.31.01.29.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 31 Jan 2015 01:29:43 -0800 (PST) Message-ID: <54CCA040.4060603@gmail.com> Date: Sat, 31 Jan 2015 10:28:32 +0100 From: Heiner Kallweit User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Felix Fietkau Cc: OpenWrt Development List Subject: [OpenWrt-Devel] [PATCH 4/4] ar8216: add swconfig attributes for ARL table flushing X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Add swconfig attributes for flushing the ARL table globally or per port. Signed-off-by: Heiner Kallweit --- .../linux/generic/files/drivers/net/phy/ar8216.c | 48 +++++++++++++++++++++- .../linux/generic/files/drivers/net/phy/ar8216.h | 8 ++++ .../linux/generic/files/drivers/net/phy/ar8327.c | 12 ++++++ 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c index 9065915..75db1f1 100644 --- a/target/linux/generic/files/drivers/net/phy/ar8216.c +++ b/target/linux/generic/files/drivers/net/phy/ar8216.c @@ -1436,6 +1436,40 @@ ar8xxx_sw_get_arl_table(struct switch_dev *dev, return 0; } +int +ar8xxx_sw_set_flush_arl_table(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev); + int ret; + + mutex_lock(&priv->reg_mutex); + ret = priv->chip->atu_flush(priv); + mutex_unlock(&priv->reg_mutex); + + return ret; +} + +int +ar8xxx_sw_set_flush_port_arl_table(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev); + int port, ret; + + port = val->port_vlan; + if (port >= dev->ports) + return -EINVAL; + + mutex_lock(&priv->reg_mutex); + ret = priv->chip->atu_flush_port(priv, port); + mutex_unlock(&priv->reg_mutex); + + return ret; +} + static const struct switch_attr ar8xxx_sw_attr_globals[] = { { .type = SWITCH_TYPE_INT, @@ -1490,9 +1524,15 @@ static const struct switch_attr ar8xxx_sw_attr_globals[] = { .set = NULL, .get = ar8xxx_sw_get_arl_table, }, + { + .type = SWITCH_TYPE_NOVAL, + .name = "flush_arl_table", + .description = "Flush ARL table", + .set = ar8xxx_sw_set_flush_arl_table, + }, }; -const struct switch_attr ar8xxx_sw_attr_port[2] = { +const struct switch_attr ar8xxx_sw_attr_port[] = { { .type = SWITCH_TYPE_NOVAL, .name = "reset_mib", @@ -1506,6 +1546,12 @@ const struct switch_attr ar8xxx_sw_attr_port[2] = { .set = NULL, .get = ar8xxx_sw_get_port_mib, }, + { + .type = SWITCH_TYPE_NOVAL, + .name = "flush_arl_table", + .description = "Flush port's ARL table entries", + .set = ar8xxx_sw_set_flush_port_arl_table, + }, }; const struct switch_attr ar8xxx_sw_attr_vlan[1] = { diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.h b/target/linux/generic/files/drivers/net/phy/ar8216.h index 5abbd55..14fe928 100644 --- a/target/linux/generic/files/drivers/net/phy/ar8216.h +++ b/target/linux/generic/files/drivers/net/phy/ar8216.h @@ -543,6 +543,14 @@ ar8xxx_sw_get_arl_table(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val); int +ar8xxx_sw_set_flush_arl_table(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val); +int +ar8xxx_sw_set_flush_port_arl_table(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val); +int ar8216_wait_bit(struct ar8xxx_priv *priv, int reg, u32 mask, u32 val); static inline struct ar8xxx_priv * diff --git a/target/linux/generic/files/drivers/net/phy/ar8327.c b/target/linux/generic/files/drivers/net/phy/ar8327.c index a8d33a8..f26a310 100644 --- a/target/linux/generic/files/drivers/net/phy/ar8327.c +++ b/target/linux/generic/files/drivers/net/phy/ar8327.c @@ -1138,6 +1138,12 @@ static const struct switch_attr ar8327_sw_attr_globals[] = { .set = NULL, .get = ar8xxx_sw_get_arl_table, }, + { + .type = SWITCH_TYPE_NOVAL, + .name = "flush_arl_table", + .description = "Flush ARL table", + .set = ar8xxx_sw_set_flush_arl_table, + }, }; static const struct switch_attr ar8327_sw_attr_port[] = { @@ -1162,6 +1168,12 @@ static const struct switch_attr ar8327_sw_attr_port[] = { .get = ar8327_sw_get_eee, .max = 1, }, + { + .type = SWITCH_TYPE_NOVAL, + .name = "flush_arl_table", + .description = "Flush port's ARL table entries", + .set = ar8xxx_sw_set_flush_port_arl_table, + }, }; static const struct switch_dev_ops ar8327_sw_ops = {