From patchwork Fri Apr 12 12:29:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gagandeep Singh X-Patchwork-Id: 52706 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2EDB71B1FB; Fri, 12 Apr 2019 14:29:35 +0200 (CEST) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80083.outbound.protection.outlook.com [40.107.8.83]) by dpdk.org (Postfix) with ESMTP id 4224F1B10D for ; Fri, 12 Apr 2019 14:29:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dsoep8fvuVdieiXISOzOJfkwAQdxh6dcHRlBk9gfroo=; b=u1YDAZQCMJyfxY/fNL5swml9pF8yfu5c0tzaeVpSw3BAfDS7XlMHmL9LCnIiNhvI/RjM6R2hrmi5SjQZi1zOcYd8E4G9mxfDzmOr+ZD8fIuFIfuxA1fsZZ23zCx6+w65VEa/Cev+za2nk0G3zE5jiQAEYLK0SR9FfV6rbL5PKkw= Received: from VE1PR04MB6365.eurprd04.prod.outlook.com (10.255.118.78) by VE1PR04MB6367.eurprd04.prod.outlook.com (10.255.118.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1792.15; Fri, 12 Apr 2019 12:29:03 +0000 Received: from VE1PR04MB6365.eurprd04.prod.outlook.com ([fe80::f5ad:f178:4c55:13e0]) by VE1PR04MB6365.eurprd04.prod.outlook.com ([fe80::f5ad:f178:4c55:13e0%3]) with mapi id 15.20.1792.016; Fri, 12 Apr 2019 12:29:03 +0000 From: Gagandeep Singh To: "dev@dpdk.org" , "ferruh.yigit@intel.com" CC: Gagandeep Singh Thread-Topic: [PATCH v4 08/13] net/enetc: enable promiscuous and allmulticast feature Thread-Index: AQHU8StQtgAuFbDs7km1CO3j2RREcA== Date: Fri, 12 Apr 2019 12:29:03 +0000 Message-ID: <20190412122840.1908-9-g.singh@nxp.com> References: <20190412105105.24351-1-g.singh@nxp.com> <20190412122840.1908-1-g.singh@nxp.com> In-Reply-To: <20190412122840.1908-1-g.singh@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BMXPR01CA0029.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:c::15) To VE1PR04MB6365.eurprd04.prod.outlook.com (2603:10a6:803:12a::14) x-mailer: git-send-email 2.19.1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=G.Singh@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [92.120.0.8] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7733f9b8-9cf3-428b-d95a-08d6bf4272e1 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600139)(711020)(4605104)(4618075)(2017052603328)(7193020); SRVR:VE1PR04MB6367; x-ms-traffictypediagnostic: VE1PR04MB6367: x-microsoft-antispam-prvs: x-forefront-prvs: 0005B05917 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(346002)(396003)(39860400002)(366004)(136003)(189003)(199004)(476003)(99286004)(1076003)(8936002)(2501003)(5660300002)(186003)(6486002)(97736004)(3846002)(6436002)(106356001)(6116002)(14444005)(7736002)(6506007)(102836004)(386003)(305945005)(256004)(446003)(76176011)(2616005)(105586002)(26005)(71190400001)(53936002)(36756003)(66066001)(25786009)(8676002)(486006)(11346002)(14454004)(50226002)(71200400001)(81156014)(6512007)(86362001)(2906002)(316002)(478600001)(110136005)(72206003)(4326008)(52116002)(68736007)(81166006); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR04MB6367; H:VE1PR04MB6365.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: RbvBf6Vy2vTLtw2WG33cNM23lNk6oyVjvfxR/eLO7Zv6LWN6HvmNwXJKRSGQy8bFxBB25rOQtTHhlOAm4fl5HxjWC+q2j1bgRnBbpaJQc++OROcCcNS87Xf0CbD2Di3UEFY55w0YPHb3zHr5kkj9YkgMrfhbPIv0hxLoAJidVTPOt2kWP64GeMko7/dKCWlDbRBNaOGct/E7HTDVIrDyfvCjZC3DaocjPV0Z1LlMW53njV78Q8m5W2eZeYXQWb/Kg0oVxEU83P/CPUT5Dy9vkQTqVJoGuhYRLZL/NhTYCePcqIyvRRknzhj5uk7QwTNtJu5gumKpexAbExXmLLvw5IR2N0IeuKTLLMlFYDu+c6lGhfSVZVjIqUcPGTmFO2NVrzsx+ey1j+1Yj3KfIjnTcSJeXomvDlF+nI3pNl2APPY= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7733f9b8-9cf3-428b-d95a-08d6bf4272e1 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Apr 2019 12:29:03.8796 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6367 Subject: [dpdk-dev] [PATCH v4 08/13] net/enetc: enable promiscuous and allmulticast feature X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Promiscuous and allmulticast enable/disable APIs added. Signed-off-by: Gagandeep Singh --- doc/guides/nics/enetc.rst | 2 + doc/guides/nics/features/enetc.ini | 2 + drivers/net/enetc/base/enetc_hw.h | 3 +- drivers/net/enetc/enetc_ethdev.c | 90 +++++++++++++++++++++++++----- 4 files changed, 81 insertions(+), 16 deletions(-) diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst index 9f575d27f..ab13211a5 100644 --- a/doc/guides/nics/enetc.rst +++ b/doc/guides/nics/enetc.rst @@ -47,6 +47,8 @@ ENETC Features - Link Status - Packet type information - Basic stats +- Promiscuous +- Multicast NIC Driver (PMD) ~~~~~~~~~~~~~~~~ diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini index d8bd5679d..6b7bbfb3d 100644 --- a/doc/guides/nics/features/enetc.ini +++ b/doc/guides/nics/features/enetc.ini @@ -7,6 +7,8 @@ Packet type parsing = Y Link status = Y Basic stats = Y +Promiscuous mode = Y +Allmulticast mode = Y Linux VFIO = Y ARMv8 = Y Usage doc = Y diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h index 3f0a2a9a3..90a383a8b 100644 --- a/drivers/net/enetc/base/enetc_hw.h +++ b/drivers/net/enetc/base/enetc_hw.h @@ -78,8 +78,7 @@ enum enetc_bdr_type {TX, RX}; #define ENETC_PSR 0x00004 /* RO */ #define ENETC_PSIPMR 0x00018 #define ENETC_PSIPMR_SET_UP(n) (0x1 << (n)) /* n = SI index */ -#define ENETC_PSIPMR_SET_MP(n) (0x1 << ((n) + 8)) -#define ENETC_PSIPMR_SET_VLAN_MP(n) (0x1 << ((n) + 16)) +#define ENETC_PSIPMR_SET_MP(n) (0x1 << ((n) + 16)) #define ENETC_PSIPMAR0(n) (0x00100 + (n) * 0x20) #define ENETC_PSIPMAR1(n) (0x00104 + (n) * 0x20) #define ENETC_PCAPR0 0x00900 diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c index d0f9e2b35..a7dddc5cb 100644 --- a/drivers/net/enetc/enetc_ethdev.c +++ b/drivers/net/enetc/enetc_ethdev.c @@ -133,8 +133,8 @@ enetc_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused) static int enetc_hardware_init(struct enetc_eth_hw *hw) { - uint32_t psipmr = 0; struct enetc_hw *enetc_hw = &hw->hw; + uint32_t *mac = (uint32_t *)hw->mac.addr; PMD_INIT_FUNC_TRACE(); /* Calculating and storing the base HW addresses */ @@ -144,19 +144,9 @@ enetc_hardware_init(struct enetc_eth_hw *hw) /* Enabling Station Interface */ enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN); - /* Setting to accept broadcast packets for each inetrface */ - psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0) | - ENETC_PSIPMR_SET_VLAN_MP(0); - psipmr |= ENETC_PSIPMR_SET_UP(1) | ENETC_PSIPMR_SET_MP(1) | - ENETC_PSIPMR_SET_VLAN_MP(1); - psipmr |= ENETC_PSIPMR_SET_UP(2) | ENETC_PSIPMR_SET_MP(2) | - ENETC_PSIPMR_SET_VLAN_MP(2); - - enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr); - - /* Enabling broadcast address */ - enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), 0xFFFFFFFF); - enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), 0xFFFF << 16); + *mac = (uint32_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR0(0)); + mac++; + *mac = (uint16_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR1(0)); return 0; } @@ -539,6 +529,74 @@ enetc_dev_close(struct rte_eth_dev *dev) dev->data->nb_tx_queues = 0; } +static void +enetc_promiscuous_enable(struct rte_eth_dev *dev) +{ + struct enetc_eth_hw *hw = + ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct enetc_hw *enetc_hw = &hw->hw; + uint32_t psipmr = 0; + + psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR); + + /* Setting to enable promiscuous mode*/ + psipmr |= ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0); + + enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr); +} + +static void +enetc_promiscuous_disable(struct rte_eth_dev *dev) +{ + struct enetc_eth_hw *hw = + ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct enetc_hw *enetc_hw = &hw->hw; + uint32_t psipmr = 0; + + /* Setting to disable promiscuous mode for SI0*/ + psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR); + psipmr &= (~ENETC_PSIPMR_SET_UP(0)); + + if (dev->data->all_multicast == 0) + psipmr &= (~ENETC_PSIPMR_SET_MP(0)); + + enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr); +} + +static void +enetc_allmulticast_enable(struct rte_eth_dev *dev) +{ + struct enetc_eth_hw *hw = + ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct enetc_hw *enetc_hw = &hw->hw; + uint32_t psipmr = 0; + + psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR); + + /* Setting to enable allmulticast mode for SI0*/ + psipmr |= ENETC_PSIPMR_SET_MP(0); + + enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr); +} + +static void +enetc_allmulticast_disable(struct rte_eth_dev *dev) +{ + struct enetc_eth_hw *hw = + ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct enetc_hw *enetc_hw = &hw->hw; + uint32_t psipmr = 0; + + if (dev->data->promiscuous == 1) + return; /* must remain in all_multicast mode */ + + /* Setting to disable all multicast mode for SI0*/ + psipmr = enetc_port_rd(enetc_hw, ENETC_PSIPMR) & + ~(ENETC_PSIPMR_SET_MP(0)); + + enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr); +} + /* * The set of PCI devices this driver supports */ @@ -557,6 +615,10 @@ static const struct eth_dev_ops enetc_ops = { .link_update = enetc_link_update, .stats_get = enetc_stats_get, .stats_reset = enetc_stats_reset, + .promiscuous_enable = enetc_promiscuous_enable, + .promiscuous_disable = enetc_promiscuous_disable, + .allmulticast_enable = enetc_allmulticast_enable, + .allmulticast_disable = enetc_allmulticast_disable, .dev_infos_get = enetc_dev_infos_get, .rx_queue_setup = enetc_rx_queue_setup, .rx_queue_release = enetc_rx_queue_release,