From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40085.outbound.protection.outlook.com [40.107.4.85]) by dpdk.org (Postfix) with ESMTP id AAD82378B for ; Mon, 17 Sep 2018 12:37:58 +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=kcvEFVAMAFZajcPZ8XYMBq3kBKxxA91IV9FwmH8BHcs=; b=kvJ8uEDkEOXITzEKh51Gzd+nMNFxDPCnf5Q+18s1uTDvqWLiFXHMPC2rcNhXDKkN78scMuv5W11cD++QnrkEe8WAeOVphB1YBSjXiSQKxCdtg7989OLjTOYXHTYBJnm3ds8SSrvXk3F+WY7cZsAm97PRs+w0ACyxezVnT00gde0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=shreyansh.jain@nxp.com; Received: from Tophie.ap.freescale.net (14.142.187.166) by AM0PR04MB4673.eurprd04.prod.outlook.com (2603:10a6:208:75::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Mon, 17 Sep 2018 10:37:57 +0000 From: Shreyansh Jain To: dev@dpdk.org, ferruh.yigit@intel.com Cc: Shreyansh Jain Date: Mon, 17 Sep 2018 16:06:29 +0530 Message-Id: <20180917103631.32304-10-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180917103631.32304-1-shreyansh.jain@nxp.com> References: <20180917103631.32304-1-shreyansh.jain@nxp.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.142.187.166] X-ClientProxiedBy: BM1PR01CA0092.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1::32) To AM0PR04MB4673.eurprd04.prod.outlook.com (2603:10a6:208:75::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 12135c00-54f4-47f8-d17f-08d61c89a24e X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM0PR04MB4673; X-Microsoft-Exchange-Diagnostics: 1; AM0PR04MB4673; 3:XrI3T29uuPbuYWCjx+1Fa6qbog5tLyr+r0ebQ/NKzpynorCY9QVZgG3fgxFrJMSmQgv6Pmllu1rxd94U3WR0Z4/6WRO/cNzVIRel1RLdFe3YDL4h8R7ar6dNjyqZihalDBX4Mkmb0Hxo3JqVR3l+ygLEbYcwhVOFp+PVslh1mkV9rB1CfrTlb8S+I/RfOVqMw8ARH6ZwoylXb8Atp1D4Etn8l37JhMLg4rpAGREVq7F4LSfK7tY/9BYQ2ba81Fb4; 25:/FV69XPs5BxmmHhTTGlyESAZV8Wa434TDmeOiWDbUTChXju0+lBEreYj9c9VGSrA6CpEl8cxf7alN+WYk4kAiYTNg7VUNsXnBSB87QUNSt+xEjflcffUdEn3LWRNxSXsBzaEjpiPpo9Q3DjZOQplVz2TusvBhHOclQG21vIQrbDWEAzJVYcRLX9GlVl0kQ4AzuJ/oryfKe8bGv+gsJDzacpCJ1JYeJ+oviyTeCQ/d+9+ECzHLPDf2vT6my6WrvSokoOyYZq5C5Vj8M3YoHyu84kQwcVl/NojspvqhWMwG9AGAYcIiVARJQok7GwspIZYp+YmKuXEs7IPPtDHmfVgOw==; 31:3qS+RFiYFFbfAncBNb+T4uklN+X0QAeT2V2OORRUs+VzR0jtbwdJ/tH602lfcW9VQhSzw5QTDMZ3+xzSLtmb1lpfRFZ1xXJSzWdRkD88Fl1lLkRldCbFJS5L17Bwm24y4o46mYb5PQ/k378n5jzOg2ms8JN6wVqAZhYVxr5zmE2yv65IMt+CGmR2Zyj0+DlHqzBox6Bsegr9+KXDFsAhAX77Oi319YCA32Eo3egosiE= X-MS-TrafficTypeDiagnostic: AM0PR04MB4673: X-Microsoft-Exchange-Diagnostics: 1; AM0PR04MB4673; 20:tMuNo3f+IKs3GVSvDQ+4aAk69uheWbzcNYLbG0720+9i/7a55NjQ8uSrvFDNf50aUPQFmNtbGpoN9LfQcPq3WAr36dHRpU5iP9B1dJF8kX/6v1/Ur7kVZWBuGYdEnRb8dSius78WaUIxNqJyAAieKStZ2S0K5E2xH/We9NwVrcYbs3hoRV0R8xNpk+9WZPgrul9KUKhYVMBuKKpY6a9YjjCD7P8/VQP8mluuVIJPVOKI+tBZmu/eHPhqJT3mQzcTf38nhA4D5gfcooz1UF/PogQY7+4U0hZtEUC2eXWMoQ2TKiAYDNTGdexz2lMndp5b3+HR5JLnz3e/SIs9SHOsKfKBRl7Hn2Iq2ASKmsN4ElgAnUfWMXwNUcNGxd6/e7uvQ2DCspg++EC/efrL3KEgwADMpC66kVKl2GuloSzUWz1N5fq9LtI8P9s5OW1/M4bWFgR22aduwm4EADIoProhGaVObc7iP3528TptYXQ5VnfLoUI3iyeEck3+KwVk+v4F; 4:ATZdTakt5msQdU25DWfZsIkc4TlqGrsepGYTs6Sj3T/4BRMFtw+nHc3PML1nVnrC71W+kU9awZb5ljsl3jdeVyWmho/90ATYauM+tunOux3oM61WELbNg6fw5cZZ+bMUpKWl4hbPBoHh5+YrpA3EGEfxIhh774StNwMVh5Q1fn+IaesYmhJjt4eQdi0n/BkehGc1bx6dV93TZmj+Y0QUL1RaIWrteHx2aB3V2EU6zHDO3Qd9gZnZv3YWPkjYDAa2SyxezS8zWWNtKE4O3hX8fOjZaV0ae03iyM2sFz/uJKd9I0ps2WXN+IzWAInHQzU2 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231355)(944501410)(52105095)(10201501046)(3002001)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699050); SRVR:AM0PR04MB4673; BCL:0; PCL:0; RULEID:; SRVR:AM0PR04MB4673; X-Forefront-PRVS: 0798146F16 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(136003)(396003)(346002)(366004)(376002)(39860400002)(199004)(189003)(16526019)(48376002)(186003)(1076002)(3846002)(5660300001)(486006)(6506007)(386003)(16586007)(316002)(36756003)(44832011)(5009440100003)(52116002)(6116002)(2616005)(76176011)(446003)(51416003)(11346002)(956004)(476003)(6512007)(47776003)(106356001)(25786009)(50226002)(2906002)(68736007)(105586002)(81156014)(81166006)(7736002)(6666003)(305945005)(8676002)(8936002)(4326008)(575784001)(86362001)(97736004)(6486002)(478600001)(50466002)(66066001)(26005)(53936002)(110426005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB4673; H:Tophie.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM0PR04MB4673; 23:STf7No8I24qyegEjM1HTybYZIwyji5cUaoWoCLZU+?= =?us-ascii?Q?sdhiDNrrlvcwtZxC5o68LEWTc9VJrJDw1zIrsjfhYSwFOa1tXegt6rv8+7jP?= =?us-ascii?Q?zrqBy8uYaWQ2WRg8TdD/msz4TRw+FxwYbt3hlYrjOoFyqqcEMS/p9lgYte47?= =?us-ascii?Q?f1Ea7z6iguG0ElWlh8yd/zK3PnU6uoAHRJ2vcB/iJfp4aRFxKqeIJ7Xvl2RG?= =?us-ascii?Q?lHU/29Z0sYJ2m2cQ5IhwbKyYbGI4U0x3mJnhuNso89DrXc87Y+l4OIiYp7W+?= =?us-ascii?Q?3h1N01QbS1zoWajp4gZ9nIGKpYwyF++0JcjZPQbTj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lJ6VQqCQk8h0eTOhBOlfxq8OxQN9FHY78HJnD0h+6rQ0Ms6Y55+zG/A9J45/gnYRpP90GG/ht5nmH+uylesHc34c=; 7:AA43/luAOs860nc4pHmYaRvu6uXWDf/U5V0q+NGwljD9k7nFI0dKGQtou/Dr9rsua4F498IuqBtahQxzpcfjECfjw42TEw0LZVqSQm7q0gwlOkVgrcTIcuBEPvaueMk4FHnhT5nphraHTsUvDzYj75oV2vUry+e1aic+BVWdVAqsWSvz8y9kWBOCCjgGbeWGC67xSM/rs2TkMpwaB861VboMqShyAYQcEQtBkrbojT8/1A3ejVOwtj1gPNcEvbid SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2018 10:37:57.1331 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 12135c00-54f4-47f8-d17f-08d61c89a24e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4673 Subject: [dpdk-dev] [PATCH 09/11] net/dpaa2: read hardware provided MAC for DPNI devices 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: , X-List-Received-Date: Mon, 17 Sep 2018 10:37:59 -0000 Firmware would contain pre-configured devices for each DPMAC backing a DPNI. This patch reads those MAC address when the device is initialized and sets it. THereafter, it can be changed through API or commands from testpmd. Signed-off-by: Shreyansh Jain --- drivers/net/dpaa2/dpaa2_ethdev.c | 79 +++++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 6 deletions(-) diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index 02cea0cd1..01b010312 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -1789,6 +1789,71 @@ static struct eth_dev_ops dpaa2_ethdev_ops = { .rss_hash_conf_get = dpaa2_dev_rss_hash_conf_get, }; +/* Populate the mac address from physically available (u-boot/firmware) and/or + * one set by higher layers like MC (restool) etc. + * Returns the table of MAC entries (multiple entries) + */ +static int +populate_mac_addr(struct fsl_mc_io *dpni_dev, struct dpaa2_dev_priv *priv, + struct ether_addr *mac_entry) +{ + int ret; + struct ether_addr phy_mac = {}, prime_mac = {}; + + /* Get the physical device MAC address */ + ret = dpni_get_port_mac_addr(dpni_dev, CMD_PRI_LOW, priv->token, + phy_mac.addr_bytes); + if (ret) { + DPAA2_PMD_ERR("DPNI get physical port MAC failed: %d", ret); + goto cleanup; + } + + ret = dpni_get_primary_mac_addr(dpni_dev, CMD_PRI_LOW, priv->token, + prime_mac.addr_bytes); + if (ret) { + DPAA2_PMD_ERR("DPNI get Prime port MAC failed: %d", ret); + goto cleanup; + } + + /* Now that both MAC have been obtained, do: + * if not_empty_mac(phy) && phy != Prime, overwrite prime with Phy + * and return phy + * If empty_mac(phy), return prime. + * if both are empty, create random MAC, set as prime and return + */ + if (!is_zero_ether_addr(&phy_mac)) { + /* If the addresses are not same, overwrite prime */ + if (!is_same_ether_addr(&phy_mac, &prime_mac)) { + ret = dpni_set_primary_mac_addr(dpni_dev, CMD_PRI_LOW, + priv->token, + phy_mac.addr_bytes); + if (ret) { + DPAA2_PMD_ERR("Unable to set MAC Address: %d", + ret); + goto cleanup; + } + memcpy(&prime_mac, &phy_mac, sizeof(struct ether_addr)); + } + } else if (is_zero_ether_addr(&prime_mac)) { + /* In case phys and prime, both are zero, create random MAC */ + eth_random_addr(prime_mac.addr_bytes); + ret = dpni_set_primary_mac_addr(dpni_dev, CMD_PRI_LOW, + priv->token, + prime_mac.addr_bytes); + if (ret) { + DPAA2_PMD_ERR("Unable to set MAC Address: %d", ret); + goto cleanup; + } + } + + /* prime_mac the final MAC address */ + memcpy(mac_entry, &prime_mac, sizeof(struct ether_addr)); + return 0; + +cleanup: + return -1; +} + static int dpaa2_dev_init(struct rte_eth_dev *eth_dev) { @@ -1868,7 +1933,10 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) goto init_err; } - /* Allocate memory for storing MAC addresses */ + /* Allocate memory for storing MAC addresses. + * Table of mac_filter_entries size is allocated so that RTE ether lib + * can add MAC entries when rte_eth_dev_mac_addr_add is called. + */ eth_dev->data->mac_addrs = rte_zmalloc("dpni", ETHER_ADDR_LEN * attr.mac_filter_entries, 0); if (eth_dev->data->mac_addrs == NULL) { @@ -1879,12 +1947,11 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) goto init_err; } - ret = dpni_get_primary_mac_addr(dpni_dev, CMD_PRI_LOW, - priv->token, - (uint8_t *)(eth_dev->data->mac_addrs[0].addr_bytes)); + ret = populate_mac_addr(dpni_dev, priv, ð_dev->data->mac_addrs[0]); if (ret) { - DPAA2_PMD_ERR("DPNI get mac address failed:Err Code = %d", - ret); + DPAA2_PMD_ERR("Unable to fetch MAC Address for device"); + rte_free(eth_dev->data->mac_addrs); + eth_dev->data->mac_addrs = NULL; goto init_err; } -- 2.17.1