From patchwork Tue Aug 13 02:52:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangbo Lu X-Patchwork-Id: 1145987 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=fail (p=none dis=none) header.from=nxp.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 466xyG4VxLz9sNF for ; Tue, 13 Aug 2019 12:49:42 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726776AbfHMCtl (ORCPT ); Mon, 12 Aug 2019 22:49:41 -0400 Received: from inva020.nxp.com ([92.121.34.13]:47234 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726453AbfHMCtk (ORCPT ); Mon, 12 Aug 2019 22:49:40 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 965261A0022; Tue, 13 Aug 2019 04:49:37 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 4BE8A1A02AD; Tue, 13 Aug 2019 04:49:34 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 2EFD0402BF; Tue, 13 Aug 2019 10:49:30 +0800 (SGT) From: Yangbo Lu To: netdev@vger.kernel.org, "David S . Miller" , "Allan W . Nielsen" , Alexandre Belloni , Microchip Linux Driver Support Cc: Yangbo Lu Subject: [v2, 1/4] ocelot_ace: drop member port from ocelot_ace_rule structure Date: Tue, 13 Aug 2019 10:52:11 +0800 Message-Id: <20190813025214.18601-2-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190813025214.18601-1-yangbo.lu@nxp.com> References: <20190813025214.18601-1-yangbo.lu@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The ocelot_ace_rule is not port specific. We don't need a member port in ocelot_ace_rule structure. Drop it and use member ocelot instead. Signed-off-by: Yangbo Lu --- Changes for v2: - None. --- drivers/net/ethernet/mscc/ocelot_ace.c | 12 ++++++------ drivers/net/ethernet/mscc/ocelot_ace.h | 2 +- drivers/net/ethernet/mscc/ocelot_flower.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_ace.c b/drivers/net/ethernet/mscc/ocelot_ace.c index 39aca1a..5580a58 100644 --- a/drivers/net/ethernet/mscc/ocelot_ace.c +++ b/drivers/net/ethernet/mscc/ocelot_ace.c @@ -576,7 +576,7 @@ static void is2_entry_set(struct ocelot *ocelot, int ix, static void is2_entry_get(struct ocelot_ace_rule *rule, int ix) { - struct ocelot *op = rule->port->ocelot; + struct ocelot *op = rule->ocelot; struct vcap_data data; int row = (ix / 2); u32 cnt; @@ -655,11 +655,11 @@ int ocelot_ace_rule_offload_add(struct ocelot_ace_rule *rule) /* Move down the rules to make place for the new rule */ for (i = acl_block->count - 1; i > index; i--) { ace = ocelot_ace_rule_get_rule_index(acl_block, i); - is2_entry_set(rule->port->ocelot, i, ace); + is2_entry_set(rule->ocelot, i, ace); } /* Now insert the new rule */ - is2_entry_set(rule->port->ocelot, index, rule); + is2_entry_set(rule->ocelot, index, rule); return 0; } @@ -697,11 +697,11 @@ int ocelot_ace_rule_offload_del(struct ocelot_ace_rule *rule) /* Move up all the blocks over the deleted rule */ for (i = index; i < acl_block->count; i++) { ace = ocelot_ace_rule_get_rule_index(acl_block, i); - is2_entry_set(rule->port->ocelot, i, ace); + is2_entry_set(rule->ocelot, i, ace); } /* Now delete the last rule, because it is duplicated */ - is2_entry_set(rule->port->ocelot, acl_block->count, &del_ace); + is2_entry_set(rule->ocelot, acl_block->count, &del_ace); return 0; } @@ -717,7 +717,7 @@ int ocelot_ace_rule_stats_update(struct ocelot_ace_rule *rule) /* After we get the result we need to clear the counters */ tmp = ocelot_ace_rule_get_rule_index(acl_block, index); tmp->stats.pkts = 0; - is2_entry_set(rule->port->ocelot, index, tmp); + is2_entry_set(rule->ocelot, index, tmp); return 0; } diff --git a/drivers/net/ethernet/mscc/ocelot_ace.h b/drivers/net/ethernet/mscc/ocelot_ace.h index e98944c..ce72f02 100644 --- a/drivers/net/ethernet/mscc/ocelot_ace.h +++ b/drivers/net/ethernet/mscc/ocelot_ace.h @@ -186,7 +186,7 @@ struct ocelot_ace_stats { struct ocelot_ace_rule { struct list_head list; - struct ocelot_port *port; + struct ocelot *ocelot; u16 prio; u32 id; diff --git a/drivers/net/ethernet/mscc/ocelot_flower.c b/drivers/net/ethernet/mscc/ocelot_flower.c index 59487d4..7c60e8c 100644 --- a/drivers/net/ethernet/mscc/ocelot_flower.c +++ b/drivers/net/ethernet/mscc/ocelot_flower.c @@ -183,7 +183,7 @@ struct ocelot_ace_rule *ocelot_ace_rule_create(struct flow_cls_offload *f, if (!rule) return NULL; - rule->port = block->port; + rule->ocelot = block->port->ocelot; rule->chip_port = block->port->chip_port; return rule; } @@ -219,7 +219,7 @@ static int ocelot_flower_destroy(struct flow_cls_offload *f, int ret; rule.prio = get_prio(f->common.prio); - rule.port = port_block->port; + rule.ocelot = port_block->port->ocelot; rule.id = f->cookie; ret = ocelot_ace_rule_offload_del(&rule); @@ -237,7 +237,7 @@ static int ocelot_flower_stats_update(struct flow_cls_offload *f, int ret; rule.prio = get_prio(f->common.prio); - rule.port = port_block->port; + rule.ocelot = port_block->port->ocelot; rule.id = f->cookie; ret = ocelot_ace_rule_stats_update(&rule); if (ret) From patchwork Tue Aug 13 02:52:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangbo Lu X-Patchwork-Id: 1145990 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=fail (p=none dis=none) header.from=nxp.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 466xyM20Bhz9sNF for ; Tue, 13 Aug 2019 12:49:47 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726601AbfHMCtl (ORCPT ); Mon, 12 Aug 2019 22:49:41 -0400 Received: from inva021.nxp.com ([92.121.34.21]:60992 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726236AbfHMCtj (ORCPT ); Mon, 12 Aug 2019 22:49:39 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 1E905200728; Tue, 13 Aug 2019 04:49:38 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 0E4A720071F; Tue, 13 Aug 2019 04:49:35 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id E6257402EC; Tue, 13 Aug 2019 10:49:30 +0800 (SGT) From: Yangbo Lu To: netdev@vger.kernel.org, "David S . Miller" , "Allan W . Nielsen" , Alexandre Belloni , Microchip Linux Driver Support Cc: Yangbo Lu Subject: [v2, 2/4] ocelot_ace: fix ingress ports setting for rule Date: Tue, 13 Aug 2019 10:52:12 +0800 Message-Id: <20190813025214.18601-3-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190813025214.18601-1-yangbo.lu@nxp.com> References: <20190813025214.18601-1-yangbo.lu@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The ingress ports setting of rule should support covering all ports. This patch is to use u16 ingress_port for ingress port mask setting for ace rule. One bit corresponds one port. Signed-off-by: Yangbo Lu --- Changes for v2: - None. --- drivers/net/ethernet/mscc/ocelot_ace.c | 2 +- drivers/net/ethernet/mscc/ocelot_ace.h | 2 +- drivers/net/ethernet/mscc/ocelot_flower.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_ace.c b/drivers/net/ethernet/mscc/ocelot_ace.c index 5580a58..91250f3 100644 --- a/drivers/net/ethernet/mscc/ocelot_ace.c +++ b/drivers/net/ethernet/mscc/ocelot_ace.c @@ -352,7 +352,7 @@ static void is2_entry_set(struct ocelot *ocelot, int ix, data.type = IS2_ACTION_TYPE_NORMAL; VCAP_KEY_ANY_SET(PAG); - VCAP_KEY_SET(IGR_PORT_MASK, 0, ~BIT(ace->chip_port)); + VCAP_KEY_SET(IGR_PORT_MASK, 0, ~ace->ingress_port); VCAP_KEY_BIT_SET(FIRST, OCELOT_VCAP_BIT_1); VCAP_KEY_BIT_SET(HOST_MATCH, OCELOT_VCAP_BIT_ANY); VCAP_KEY_BIT_SET(L2_MC, ace->dmac_mc); diff --git a/drivers/net/ethernet/mscc/ocelot_ace.h b/drivers/net/ethernet/mscc/ocelot_ace.h index ce72f02..0fe23e0 100644 --- a/drivers/net/ethernet/mscc/ocelot_ace.h +++ b/drivers/net/ethernet/mscc/ocelot_ace.h @@ -193,7 +193,7 @@ struct ocelot_ace_rule { enum ocelot_ace_action action; struct ocelot_ace_stats stats; - int chip_port; + u16 ingress_port; enum ocelot_vcap_bit dmac_mc; enum ocelot_vcap_bit dmac_bc; diff --git a/drivers/net/ethernet/mscc/ocelot_flower.c b/drivers/net/ethernet/mscc/ocelot_flower.c index 7c60e8c..bfddc50 100644 --- a/drivers/net/ethernet/mscc/ocelot_flower.c +++ b/drivers/net/ethernet/mscc/ocelot_flower.c @@ -184,7 +184,7 @@ struct ocelot_ace_rule *ocelot_ace_rule_create(struct flow_cls_offload *f, return NULL; rule->ocelot = block->port->ocelot; - rule->chip_port = block->port->chip_port; + rule->ingress_port = BIT(block->port->chip_port); return rule; } From patchwork Tue Aug 13 02:52:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangbo Lu X-Patchwork-Id: 1145989 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=fail (p=none dis=none) header.from=nxp.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 466xyL094lz9sNm for ; Tue, 13 Aug 2019 12:49:46 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726807AbfHMCtn (ORCPT ); Mon, 12 Aug 2019 22:49:43 -0400 Received: from inva021.nxp.com ([92.121.34.21]:32790 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726316AbfHMCtk (ORCPT ); Mon, 12 Aug 2019 22:49:40 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id E04AB20071F; Tue, 13 Aug 2019 04:49:38 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id D0A2C20015A; Tue, 13 Aug 2019 04:49:35 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id A8DAB402F0; Tue, 13 Aug 2019 10:49:31 +0800 (SGT) From: Yangbo Lu To: netdev@vger.kernel.org, "David S . Miller" , "Allan W . Nielsen" , Alexandre Belloni , Microchip Linux Driver Support Cc: Yangbo Lu Subject: [v2, 3/4] ocelot_ace: fix action of trap Date: Tue, 13 Aug 2019 10:52:13 +0800 Message-Id: <20190813025214.18601-4-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190813025214.18601-1-yangbo.lu@nxp.com> References: <20190813025214.18601-1-yangbo.lu@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The trap action should be copying the frame to CPU and dropping it for forwarding, but current setting was just copying frame to CPU. Signed-off-by: Yangbo Lu --- Changes for v2: - None. --- drivers/net/ethernet/mscc/ocelot_ace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_ace.c b/drivers/net/ethernet/mscc/ocelot_ace.c index 91250f3..59ad590 100644 --- a/drivers/net/ethernet/mscc/ocelot_ace.c +++ b/drivers/net/ethernet/mscc/ocelot_ace.c @@ -317,9 +317,9 @@ static void is2_action_set(struct vcap_data *data, break; case OCELOT_ACL_ACTION_TRAP: VCAP_ACT_SET(PORT_MASK, 0x0); - VCAP_ACT_SET(MASK_MODE, 0x0); - VCAP_ACT_SET(POLICE_ENA, 0x0); - VCAP_ACT_SET(POLICE_IDX, 0x0); + VCAP_ACT_SET(MASK_MODE, 0x1); + VCAP_ACT_SET(POLICE_ENA, 0x1); + VCAP_ACT_SET(POLICE_IDX, OCELOT_POLICER_DISCARD); VCAP_ACT_SET(CPU_QU_NUM, 0x0); VCAP_ACT_SET(CPU_COPY_ENA, 0x1); break; From patchwork Tue Aug 13 02:52:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangbo Lu X-Patchwork-Id: 1145988 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=fail (p=none dis=none) header.from=nxp.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 466xyK0jgRz9sNF for ; Tue, 13 Aug 2019 12:49:45 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726820AbfHMCtn (ORCPT ); Mon, 12 Aug 2019 22:49:43 -0400 Received: from inva021.nxp.com ([92.121.34.21]:32804 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726549AbfHMCtl (ORCPT ); Mon, 12 Aug 2019 22:49:41 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id A342020015A; Tue, 13 Aug 2019 04:49:39 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 93208200732; Tue, 13 Aug 2019 04:49:36 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 76AB940305; Tue, 13 Aug 2019 10:49:32 +0800 (SGT) From: Yangbo Lu To: netdev@vger.kernel.org, "David S . Miller" , "Allan W . Nielsen" , Alexandre Belloni , Microchip Linux Driver Support Cc: Yangbo Lu Subject: [v2, 4/4] ocelot: add VCAP IS2 rule to trap PTP Ethernet frames Date: Tue, 13 Aug 2019 10:52:14 +0800 Message-Id: <20190813025214.18601-5-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190813025214.18601-1-yangbo.lu@nxp.com> References: <20190813025214.18601-1-yangbo.lu@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org All the PTP messages over Ethernet have etype 0x88f7 on them. Use etype as the key to trap PTP messages. Signed-off-by: Yangbo Lu --- Changes for v2: - Added this patch. --- drivers/net/ethernet/mscc/ocelot.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 6932e61..40f4e0d 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1681,6 +1681,33 @@ int ocelot_probe_port(struct ocelot *ocelot, u8 port, } EXPORT_SYMBOL(ocelot_probe_port); +static int ocelot_ace_add_ptp_rule(struct ocelot *ocelot) +{ + struct ocelot_ace_rule *rule; + + rule = kzalloc(sizeof(*rule), GFP_KERNEL); + if (!rule) + return -ENOMEM; + + /* Entry for PTP over Ethernet (etype 0x88f7) + * Action: trap to CPU port + */ + rule->ocelot = ocelot; + rule->prio = 1; + rule->type = OCELOT_ACE_TYPE_ETYPE; + /* Available on all ingress port except CPU port */ + rule->ingress_port = ~BIT(ocelot->num_phys_ports); + rule->dmac_mc = OCELOT_VCAP_BIT_1; + rule->frame.etype.etype.value[0] = 0x88; + rule->frame.etype.etype.value[1] = 0xf7; + rule->frame.etype.etype.mask[0] = 0xff; + rule->frame.etype.etype.mask[1] = 0xff; + rule->action = OCELOT_ACL_ACTION_TRAP; + + ocelot_ace_rule_offload_add(rule); + return 0; +} + int ocelot_init(struct ocelot *ocelot) { u32 port; @@ -1708,6 +1735,7 @@ int ocelot_init(struct ocelot *ocelot) ocelot_mact_init(ocelot); ocelot_vlan_init(ocelot); ocelot_ace_init(ocelot); + ocelot_ace_add_ptp_rule(ocelot); for (port = 0; port < ocelot->num_phys_ports; port++) { /* Clear all counters (5 groups) */