From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50042.outbound.protection.outlook.com [40.107.5.42]) by dpdk.org (Postfix) with ESMTP id 635D01B474 for ; Wed, 26 Sep 2018 20:06:08 +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=eA0O3JbYdNba7ByFAcm6X/p/zOf+/UPXcOXcQqxBsvM=; b=poypRr67FlTMqEd4zsHquG+WoyN8rsh00u+SgBjbh6BkSjlFyJNHIwL/lARsBpOf8u0cyH6zXO6WoC6xKmb32Yb6BD26SvlBc+qpf747t32czB8CnRoBty8ReCg+zUKQlW/5yn6ONtX+OdnQrEfLYbfZa5yxnF3o4oQ23C7Hb9E= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=shreyansh.jain@nxp.com; Received: from Tophie.ap.freescale.net (14.142.187.166) by AM6PR04MB4679.eurprd04.prod.outlook.com (2603:10a6:20b:1c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.22; Wed, 26 Sep 2018 18:06:05 +0000 From: Shreyansh Jain To: dev@dpdk.org, ferruh.yigit@intel.com Cc: thomas@monjalon.net, Shreyansh Jain Date: Wed, 26 Sep 2018 23:34:34 +0530 Message-Id: <20180926180440.31726-10-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926180440.31726-1-shreyansh.jain@nxp.com> References: <20180917103631.32304-1-shreyansh.jain@nxp.com> <20180926180440.31726-1-shreyansh.jain@nxp.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.142.187.166] X-ClientProxiedBy: MA1PR0101CA0014.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::24) To AM6PR04MB4679.eurprd04.prod.outlook.com (2603:10a6:20b:1c::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f21780e6-d9f5-4b03-6b80-08d623dabb82 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM6PR04MB4679; X-Microsoft-Exchange-Diagnostics: 1; AM6PR04MB4679; 3:nTfqk22x65PI8RPP1HmgMR6m8xDgtQQP2RVkSyIXudqoIRgENR14GD1rmLUfTgGWWTzsglTyqfmdg0WTRJoCIYihco3++wf9keOoGJU8Ryl+yTa/6xwDoEP89dnbznajvMlXh5hsH3Kb67jzCaKdtjEs5fefX14jG1OtsEWaTH1M5wE7Nheh8AumJELwOx/5oFCf5GIPM9D/+eiFKcMS9/ZvTTP7y2AWMuFPIU7sQD91ieXdDs86VjS7ftcbL2Sw; 25:y4MzLR4CLSpwDPyRfjC/V0Fc5m/pjf64SjZpsQMoOlgDQLzhM9l8cEe3mkKSq3zB91h8ieYjmeJ4pgxdc2BQmsFnqxD6+kSV4cuTOaA4ERmkV6wdamOQyDSxEreNvVWBYYV4ppsCrbqVFVbh1qekj/bUj/Ymn9myfqbHjil9hSSqqMAiZ2zTLZN0F7tGL+sQwhw44cK3w4rzyF9B0w48q8G0E5ihl/HnPX/xZPL0QBwPVhf5iSDvqVKRHt213o/iD5E3ER5X7x13h62TJ+pvFMENdAJWJ0hyPROLKJthQdBsbktCMA8+u9SgAPf2SGCpEVw0/AFp4NImTRgfEZr3rw==; 31:KDDybPR3zGQ0Ow+JUJebkLNC/DAn4/4wabHf/LthCX7J9WGM/NIQ7STSLH7IJndi1ECZkQ7vh/uOuR9tAhJuryFdPGZI0WHOd1/eALzE/TUHlGsFKJsRuqtFSl4XUi/ZzuVm69/JyCwQjiAC3yhK8GMjNs1QebRAKR5P+FVmu+OoRpdFUpjp9NeVp3YtgbxZFQF82Ag/VwWfm3wGwbFQ+QPSjBTQbytfiHCxFG4pcds= X-MS-TrafficTypeDiagnostic: AM6PR04MB4679: X-Microsoft-Exchange-Diagnostics: 1; AM6PR04MB4679; 20:edAhBNacy5JIV0wo1Py6RTn2uOgwFi7ZSSnKbaHX4FoieMUmsHDvWyiqhbM/qFzozf6pKEG8ldR4pDNsnnfquKMzHZ1UotNjI7O6KkeUJec+ayNdw/5RbmnwKtTkeIEFtKHhn4a0EfGFQi8dZy7iNIwYYGREq2H8oBuYtH4JNMBOPa2WSXoiuBCsbFUg/G5zgUUvCebwja/yCbUCbuLDGR7s0zvEeDjNJnlVh0Cd+UngXiVsyrRhfyLfOKtqnjaKr6yrUdoqJrn8F/94WwL6S/pam/xmPsvQNyHhYUJ8WOa/voyD9wY5jlMsPVjhJJrel/C2To0I+iXVw/0MnHsPPhroV1kpggHO0aCTcsas2lEWDBhexXxyT1WAvYnRQQE6NrNigF3jasjMSzUQSBevecJEMSxMaE4e1+zei+jTvx9ZxFIwxINDfD/yB70mPpqlSy+xZFnsFezW87kvLL5Fja7uIBPWjYgejOD5TRX0HSF8p6DCA5XI2QUSMKb1GyaQ; 4:pgdLwK+UZNtA50awqLx9rAdE2+hY5LGKzeDGSuBgCnFjsKTp1K9/rDfg/LB98uTWTLWyaPytU7/Qzr/3RFICWx9cQpZKFfOwBUrixhsip3FeJaC7lVUZHjGvvAECPWX/XmhvOzOFU4V6oPTFXKDzhrq0gOYTfaJiUbJNNAhfhNAR1TY4JX5uD+X/6HatOr8vPWXRWcUKtfa4chdrnDrS3xR0Zqx6WtU3u/dWdERSOauLMCuRqdBwy2bRDgaggMm3t1e0yeLBhlF3MNwZq1hlTp8iHc6Kkl6oQRzt8WpZIoLd04v7cbFGbZSK4655xJoc 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)(3231355)(944501410)(52105095)(3002001)(6055026)(149066)(150057)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123560045)(201708071742011)(7699051); SRVR:AM6PR04MB4679; BCL:0; PCL:0; RULEID:; SRVR:AM6PR04MB4679; X-Forefront-PRVS: 08076ABC99 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(136003)(396003)(346002)(366004)(39860400002)(189003)(199004)(11346002)(50226002)(446003)(47776003)(44832011)(956004)(476003)(106356001)(486006)(2616005)(6512007)(66066001)(305945005)(7736002)(6486002)(105586002)(36756003)(86362001)(478600001)(8936002)(16526019)(81166006)(50466002)(186003)(26005)(25786009)(8676002)(55236004)(48376002)(81156014)(4326008)(3846002)(6116002)(1076002)(6666003)(52116002)(34290500001)(5009440100003)(2906002)(16586007)(51416003)(316002)(97736004)(6506007)(76176011)(5660300001)(386003)(68736007)(53936002)(110426005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR04MB4679; H:Tophie.ap.freescale.net; 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-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM6PR04MB4679; 23:Lo6iGEpyKeAEtLIyvcjjD2mOCa59wHn7dODjiAKYU?= =?us-ascii?Q?MsZs8prWdiY6RM9FXUuwUc1jfPZkHF2BfFHlbv2tEWf0j9WW94qHxrWxztJj?= =?us-ascii?Q?9JhbC5bTpan8gWyZDnGPp5BJwtgw+nFxkZebQR1RSDIALk2eZfoJBmWxNFUc?= =?us-ascii?Q?yKy1p1auDSoXXeA03Z1l9kXK3iKUdZQxIEek2jMlCa54K8UY4DP4yOOpPIlH?= =?us-ascii?Q?AA08lRXoH0nA3dbFs0DWVEz4wPG9qsGqmec0t8UOeSsnh2h92CSMc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8JQLysq6AcYAMk6lXgsos5TKHOhdPi8WnKyQxXFEnHqQ==; 5:U1pudz97ujotlI8hLyYMYD8L1xTVFce2qc/RWcZh1DEvRdXaUbtPVEvsRJvLMegbRLXtOZaxJQnHDDdkwhsnk6BsgEXgbZNYFehfsdzymp4Kr77Ej4ljB8F43nlzhKrOz5a0YPbWVTu8gAfHZqCfLgjN8bUfnFD27DMnqlR4ztc=; 7:9+a9mLCrpyIRzyLreJAGY/dy0+ecN65yQWMTydO1d900QjSOdfQfHxt7+9Sj3KUF/gAVkcECGcUlNg386k8nrjjSaLBOCxbmB5i59h80zmkshzkh7ghr2xlhhTgAzgSBUf+DErc0HnCsNbJuz//xHtPFUC8wYEGTsenQsmYtTbZ6N2i/EUbI2G/pfny1NABj4+ZoIDPAZOlO1kY86WbLzSi8F2yPhApgGAHJd3NnPD8W7D7ZjrOPfCN1cItnhu6B SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2018 18:06:05.8983 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f21780e6-d9f5-4b03-6b80-08d623dabb82 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4679 Subject: [dpdk-dev] [PATCH v2 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: Wed, 26 Sep 2018 18:06:09 -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 91b1d5916..6ccb8ab15 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