From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00086.outbound.protection.outlook.com [40.107.0.86]) by dpdk.org (Postfix) with ESMTP id E3B361B49D for ; Fri, 12 Oct 2018 12:05:54 +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=cqSD9gLyhH7cSHx4FVLLvBiMHtndrz7A/faOfPdrnDI=; b=oogle8GqTdUw2Ndk1qkgb/u0WsWKpJWQmsiJWH5CQQoXlBGs8293AoOncpxeKk6obEVJjpMSbUc11UhnQtgDDCKssYXaljCaQ68QJKiAbVcIsCRwx7ZDcn+G5rWuTVx6UXJJ0joJO/niLEBXqNa4Q3pVnFHd98x+4e8bospXTkU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=shreyansh.jain@nxp.com; Received: from Tophie.ap.freescale.net (14.142.187.166) by AM0PR04MB4676.eurprd04.prod.outlook.com (2603:10a6:208:75::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.25; Fri, 12 Oct 2018 10:05:53 +0000 From: Shreyansh Jain To: thomas@monjalon.net Cc: ferruh.yigit@intel.com, dev@dpdk.org, Shreyansh Jain Date: Fri, 12 Oct 2018 15:34:20 +0530 Message-Id: <20181012100426.29349-10-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181012100426.29349-1-shreyansh.jain@nxp.com> References: <20180926180440.31726-1-shreyansh.jain@nxp.com> <20181012100426.29349-1-shreyansh.jain@nxp.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.142.187.166] X-ClientProxiedBy: BMXPR01CA0004.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:d::14) To AM0PR04MB4676.eurprd04.prod.outlook.com (2603:10a6:208:75::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c62e4d5c-836e-46ba-3fa3-08d6302a4bec X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM0PR04MB4676; X-Microsoft-Exchange-Diagnostics: 1; AM0PR04MB4676; 3:3iA3BqsPzQQHJMAhri8gqKTM3kc3VTi73tQFli7PvPpIgavy7NL2N4PLeUoMvo+jq67xqoyXg9asArwEZmv1rALGlup+cPDITvBVizRFN/wUtqYj1vA+rZHh4snehz/8V5xwllDryBmKSWKScdws7OYrX+Ci1GuSujaGIKOMc48PhO8aLCD2YyMp/Dw2KZATTYCcL4fKDr9PvKPLE7ElBjncUr56G8sTxrOtmnRkbLVVrq8880V+HiEIELJDmSMm; 25:rXuRCRsTzLFHYnh38PtbCoUgxGNE4D9T2IxPOyI4Y55ea/kgkJw4XmB9By01wGDvFnBeek8dV0EhNkse/wUiU5nqNzOMg/sufaxNjdQNpUPGXSwc50+tBcXGEUiI4K5A1505tORq7ooQtQZ+kIi0un8QDklH0s5S4M6wgeKzufyDFQFMbFKxTkDDZSewVvJnu6x9wed0FjJruSTEIGy2LuF34MEXXuPhct8b+MFA4xOR0dNz1Ggh5mTMLxCCpnjtxj59k+V4kO2LkmAMjpdwB/tx8b/JHTIMlIO5bGYvj5NnXlaBhhOJJKK5kfCnB+kKMsWhGunqMbtO8PcaASeLFQ==; 31:e6GI/EbuMOcI85tqjId69gxxCs0FABWlBV8RDSWngkZw1PROL9/Tsgrqyos2qlR1gFY00Qdt6xQ9DH1qNHO0D4GyAspwYQfs5FgNp6J7WOvvetVL+qPmvc74+LFchOXFJui4/mR80B8Lo2o3ZeTiguG3cTxYKzb6dnCw8BfuWA5Is2bhUNbJaKrC0P+X/pdczOx62WRttKcB5vjNWs9IHxqqD03vEuebLF0HUQN8ZyE= X-MS-TrafficTypeDiagnostic: AM0PR04MB4676: X-Microsoft-Exchange-Diagnostics: 1; AM0PR04MB4676; 20:Q4vOjD5MyTMqJ0huvubh1bIil1EcyKz1ezyXcwVlv1VR4hchWmyvLV1yrByGU16VwZVXWbODN1fGrLGlFSDnm158Xp/JRMChnDgvd7VY6mOKasoeoKkmWcwW3nJUdlDg4qz40A/N3ZplKVPgPxpHKsxfZwug3eYPmJzM6eaxRp/vNiu5xcoJBNJKZGa0jDsrh+veyF1xnLM9jv3TwPXUnd0h+CBNM/QuxXLuegB5dfS+zwJB/B+0JJ9+Nh8l5ck18CnpZUJmw/C2kkXqxNC7KfxU5URzPD7uvelhskHG4kjdux9Y1JvETc4wmYf0pog8nOFOXrkdPAB4j79KtL9/1llPP1298uwK/8hvESm3YPy8ZwhwaMbaMZwfJABD+6hzJMvn2rtZ0kSc/hCEw2RaYAasz+HfmYN+rCnnvKuZ1FQjgTp2x0lp/wqEIm/lC6trMtldFyBiJPEW3HRaFnz0TPTHcl4ZuRByhAttqHjGG4Au7VhhmZP5b++E5DyST2NJ; 4:PItmWiA8ROGCWmdGLMkOJqrTs2TKNUlNDgSc7th66Z3LCHsxDlGa+QOQg8E4g7S/V8TWfgTzHQJTQoes0BTUlYSIsnUP6uA635L6Kanq1r+7oZhP8EwSU9LZ4KQjfZALCtEfmripa5uJtMQzHOGU3GJ6XFNI9PwZ6g8cJWA8DhWcLu9aA+I4Kgv/UCgKXKfKqtgeoabe/KoUTsFe3/K8RY13s8zXTQQuoL1HmWQ7mpvKcVNIyfIEN2BKau/w2CYSLz5Y3Nzx+aLEHY+SgYVBFu+H53iknG8ZOaNHjjDcOho2R2exXxmLorydMitHz5vf 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)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(52105095)(6055026)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051); SRVR:AM0PR04MB4676; BCL:0; PCL:0; RULEID:; SRVR:AM0PR04MB4676; X-Forefront-PRVS: 0823A5777B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(396003)(346002)(366004)(136003)(39860400002)(199004)(189003)(2906002)(52116002)(16526019)(53936002)(8676002)(478600001)(186003)(386003)(446003)(105586002)(7736002)(106356001)(6512007)(6116002)(86362001)(3846002)(81156014)(50226002)(68736007)(1076002)(47776003)(5660300001)(6506007)(8936002)(78486009)(36756003)(316002)(26005)(66066001)(6666004)(25786009)(55236004)(81166006)(11346002)(48376002)(76176011)(44832011)(2361001)(956004)(51416003)(2616005)(97736004)(1006002)(50466002)(486006)(476003)(305945005)(16586007)(6916009)(4326008)(6486002)(2351001)(110426005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB4676; 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; AM0PR04MB4676; 23:De1oJ2H/hv4n9UsofrnWKXz0iat0DymonUQ1cpTL4?= =?us-ascii?Q?PHC5QjfmVJt4PP8Tde3FUZKSb1SerVvAM4kV/SkJqJ/TKNmDmJmte2HOoAZ0?= =?us-ascii?Q?8SrLMRBdZEFZpXJ6VtV4NBIiwWi4iLjUUn7/JDe1FCKNs0KwdFhUaPd/hkXU?= =?us-ascii?Q?hSCeAbGYQz4Q8m8Cky4JYWZmMnVMnayuL0yrR5u5B7FDGpLoLpKXgwgF5odX?= =?us-ascii?Q?JUyvZu7d9O9CIp+lTZ+mVNZ9Kf33PvMc2QWAKFvm7lKNjpALL9A0D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Rj2ynRv/aug3DdagzP0n9zwbHI520uLRMPous6?= =?us-ascii?Q?xYVDPTFFm1y5MeeXJyI55N6H6hfERCQXbzV1G4oVzePfiKOxgem10b4jROh6?= =?us-ascii?Q?ece/jkJZOEiTOl7OLDb4VEJQCIf8UVk52JCLQfjjpyK+PtEOk7nagKvNqhIE?= =?us-ascii?Q?inFweqO8L76dtDZQHcKFqjbb8kSLLAgUz+OFAfnwdWk?= X-Microsoft-Antispam-Message-Info: AEENfRQHjFiJS2ippnBSknVrbeKnI6M6EfMWUVk5309CfH0VUnqLckqNqRWrNKoz6ayDTWsk2Q4nFDgIQZVNTtin0cy2344ZcMNiTpqiSbB3Q5Ze2pqWIkGMCdutVGu1U81OROW2yZe5hGE672oTFQbFqESASEOZvASMU5fvpcsC1lrYv53xKFWMVUMjvTrcKfXKW1z3geDLvm3pkPt+7yBI/oGls2bItK8NtsEYIi/dqE9ka7YRDTQiSFLTJe/oLchGTIpBpxTKZUywDAI34jTNscFBYEUU3zBCQoqxQZIyYsgjbr4r7Afvif6Ylg7rLRdaCTrcL1V8zb1BPlYatpeECN6MbvcWqp7Em3qMwVI= X-Microsoft-Exchange-Diagnostics: 1; AM0PR04MB4676; 6:UFz1q38Fgeu1k3uKMVnZ9d8QIWylvwMa0hBd6M949KOylxpvafjB00nLmJ0t16fIWU7+36bfH1pvjPUL1DhQMNDJrsmvyACnfEYhD/NKGnLBJ9r1Ycv8OflIyZvO7aSyXLhgJBxW2X6SmR1uHlA0skUHpuwhs/kjOd/wSFrG8WS/L1RURiebvInjJ5OQ8LxLIOboC91NLuggVXN0g0UepO4cbpYdPXkVuaRUB9gmWG7Ehmo0qQpNguMyqR6vAiU0KI20OxFHiu27Yc4yycpsxmw0H4yQv6J6m2nJXC+wdIY6/WxwgYXRX5+vY8Xfxy431WvjltV86UDj5yfCctu0lo+YHINvOoEbOC6S/LMKyTrCuZPkxAEXaGuqyzdEgWSfexKW0LtmC7A+bTqcIFqhehBrC7QTSK3H6d7S/A8Tm1KOOCjGb6NPEpkKzpYbXDZxKF2Hl8Ytbc0ut5u7q8D8kA==; 5:eXH17qb6UR8rqSlMzM7SwucWxtNqVuhND1ZoWYCODvMu/Hv+y4owL6/j12pIcdGcGqj1ZVfVwwfdZqJpjgb5WkjRc9f7I52PnGXBI8xefMzQPX6I/LNcBqp3foQPFesoR7hS7qShYOCAUNtBRxFBUOXIc2BTECQH9BHqhe/K9XA=; 7:AbwXYP345Ic4ClxL+O1/VsnZStbyJZGgxoeaHukTGG8weGUfufiOmRITAdAgl3wrWwmoXnK98D/zJHvT0ZeHQHk8UTjbqsYSe1HCtWHEIWSOJYNNZFTx4zGoOfElyzNbgc3Bszc32AlsrtdNFsMfrlM5c5K7GXMvrYHsM/6svV2WnLMYc48c18jsKOKD3qja1Coeg13v8MTQbgTQ5pZrQge8yt/ZP4A0JV+CJ+GI5IJy81TKSHKvtVlXu4NXzDhd SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2018 10:05:53.0180 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c62e4d5c-836e-46ba-3fa3-08d6302a4bec X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4676 Subject: [dpdk-dev] [PATCH v3 09/15] 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: Fri, 12 Oct 2018 10:05:55 -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 bfe78c051..522a827d4 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -1786,6 +1786,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