From patchwork Mon Aug 12 10:48:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangbo Lu X-Patchwork-Id: 1145626 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 466XZ76BhMz9sNF for ; Mon, 12 Aug 2019 20:45:51 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728001AbfHLKpv (ORCPT ); Mon, 12 Aug 2019 06:45:51 -0400 Received: from inva021.nxp.com ([92.121.34.21]:36710 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727966AbfHLKpu (ORCPT ); Mon, 12 Aug 2019 06:45:50 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 25BCC200215; Mon, 12 Aug 2019 12:45:48 +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 3C6A4200084; Mon, 12 Aug 2019 12:45:45 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 02389402F0; Mon, 12 Aug 2019 18:45:41 +0800 (SGT) From: Yangbo Lu To: netdev@vger.kernel.org, "David S . Miller" , Alexandre Belloni , Microchip Linux Driver Support Cc: Yangbo Lu Subject: [PATCH 1/3] ocelot_ace: drop member port from ocelot_ace_rule structure Date: Mon, 12 Aug 2019 18:48:25 +0800 Message-Id: <20190812104827.5935-2-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190812104827.5935-1-yangbo.lu@nxp.com> References: <20190812104827.5935-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 --- 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 Mon Aug 12 10:48:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangbo Lu X-Patchwork-Id: 1145628 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 466XZB5FZvz9sNC for ; Mon, 12 Aug 2019 20:45:54 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728031AbfHLKpy (ORCPT ); Mon, 12 Aug 2019 06:45:54 -0400 Received: from inva021.nxp.com ([92.121.34.21]:36728 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727691AbfHLKpu (ORCPT ); Mon, 12 Aug 2019 06:45:50 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 00969200084; Mon, 12 Aug 2019 12:45:49 +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 5028320064C; Mon, 12 Aug 2019 12:45:46 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id A7464402D2; Mon, 12 Aug 2019 18:45:42 +0800 (SGT) From: Yangbo Lu To: netdev@vger.kernel.org, "David S . Miller" , Alexandre Belloni , Microchip Linux Driver Support Cc: Yangbo Lu Subject: [PATCH 2/3] ocelot_ace: fix ingress ports setting for rule Date: Mon, 12 Aug 2019 18:48:26 +0800 Message-Id: <20190812104827.5935-3-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190812104827.5935-1-yangbo.lu@nxp.com> References: <20190812104827.5935-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 --- 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 Mon Aug 12 10:48:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangbo Lu X-Patchwork-Id: 1145627 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 466XZ82pVSz9sNC for ; Mon, 12 Aug 2019 20:45:52 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728015AbfHLKpv (ORCPT ); Mon, 12 Aug 2019 06:45:51 -0400 Received: from inva021.nxp.com ([92.121.34.21]:36752 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727992AbfHLKpv (ORCPT ); Mon, 12 Aug 2019 06:45:51 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id ACAE42000CE; Mon, 12 Aug 2019 12:45:49 +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 0AB0120064E; Mon, 12 Aug 2019 12:45:47 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 58BC74030E; Mon, 12 Aug 2019 18:45:43 +0800 (SGT) From: Yangbo Lu To: netdev@vger.kernel.org, "David S . Miller" , Alexandre Belloni , Microchip Linux Driver Support Cc: Yangbo Lu Subject: [PATCH 3/3] ocelot_ace: fix action of trap Date: Mon, 12 Aug 2019 18:48:27 +0800 Message-Id: <20190812104827.5935-4-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190812104827.5935-1-yangbo.lu@nxp.com> References: <20190812104827.5935-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 --- 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;