From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D67DF42B42; Fri, 19 May 2023 05:01:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B15542D61; Fri, 19 May 2023 05:00:32 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2096.outbound.protection.outlook.com [40.107.243.96]) by mails.dpdk.org (Postfix) with ESMTP id EAACA42D61 for ; Fri, 19 May 2023 05:00:29 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oWY+KP6rGCtkgkO5ZPlAqGEQ6h3ZJQGwUgGUswvVnXMpAufSXXkxRhS+c7Qr14mW/DdedurtHvMLr7Qe67HyAkPt/y5fcrtYlNk/NJgZQvjPZvLXgwar1y5cghbsnjGkgwV1XGXdDki/qaC2Q5llQQ/wCNoKu2Dg5+S99o/cmpfg3NvCoIbjvbAxAu/6kCMIpQfPD2h3i5qPpMbxC0KQYC0gFh1RxzOs7oGMFzxeDCHlTow3348Bg6NnouMunh2IgYJ55INmQG40QkKVk9uFDqwczpqWlQ1E6S4nO2Z0ZtZvoss+dNpneLHvN/ny3RkEVUosOT5ND75U4EIJer11ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9pyln5Nd0iSUFQYbVUhKNH7mJBGbic/KSb+FG03Ding=; b=OUVr194TzCYBvx1ABS4gltzln2UNiGnUqPrQ2TXDY8677uXX6juJYqNc9bEOTpxJ4VbfYE23BXRFIaA3oN/ePGNJPahy8mfSdRqA/0EoL2HytdB3NyaG/L0h3eb0OdGzI2sHp/5auiOrMZlNmP7AI6zWMpWtq9Wtijb0cmk8q7EXiGA73TxB3q97Du2E+RS8zWTlJUfERm4clIwADUyfkiGXkYCMF8cQOeInhjpxzSw/GuKqB6K09UMqvp/iQo0nWOpg6th06F+vbHnE6/IRdmmyYqqan+SadoTznlwIk/3AkXfP/FneHtsZ18UT3al3u8uORkMALYiY46Pe9aotfg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9pyln5Nd0iSUFQYbVUhKNH7mJBGbic/KSb+FG03Ding=; b=Yid6xLzW1w+U53NEcJ1SklhbGMVVfqbrhSUAQdd1RcQ/Tl+GOTZUa2bM1FOknCnoTpE6tVNSegcvsSrZFeoVSPkb3LesMvTOOp1gyDzZAJKOcLOHuqiBp60PNipX0CUAtCJ7t/ruF4izv6MosfGSo5Admx/NL54w+F50HnxvCoU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by SJ0PR13MB5769.namprd13.prod.outlook.com (2603:10b6:a03:40c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.30; Fri, 19 May 2023 03:00:28 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ac2e:52b6:82ec:4994]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ac2e:52b6:82ec:4994%3]) with mapi id 15.20.6411.017; Fri, 19 May 2023 03:00:28 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH 8/8] net/nfp: revise the logic of MAC address Date: Fri, 19 May 2023 10:59:50 +0800 Message-Id: <20230519025950.1642943-9-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230519025950.1642943-1-chaoyong.he@corigine.com> References: <20230519025950.1642943-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR01CA0005.apcprd01.prod.exchangelabs.com (2603:1096:4:191::23) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|SJ0PR13MB5769:EE_ X-MS-Office365-Filtering-Correlation-Id: 4f936bb3-9104-49ea-1807-08db58153370 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +KG+PsIiIJlySwYpItbA0XMwgVVHWr4yMJuZjCJlJGpy4mjr00yGUGFjMoyTahJOZ6UXLT0uLTNLdYFpDqlP7ZrjWkT6Z1xRLKeQ69eZFs6Te260sUnDQyzpiIzO8/2Uc4BItrK7othqHeVJEC6/P2Q6C8NUtZwoZ83k9l71CXh3PefXOh0fJXgoFnoAvIPddPW319JtWmkcujluLXPrI0Nw4Zo7rK/gY1OwHXOC7xS9mIEcAlxYoB2VxcsGP+FEmRwalRfBDJb8L1o3/SxjZNjoBNWOFUufbcJaQRW9xEBkqYjZ8peA9LGWSPOlwNlHusn03gdJisAm/RJNk4SSUPLQVz0eTCswlOOyK3liHcx43Gl0P9doCQcILjn3KfOuTZh5v5uhehVifgulNNhfUckVSAe46yd+H20m/rSK8Kk3ve4RJplisDkVL1az04qzCtiCXo+MhL/kY9RUvmtO2FXN81ZRL2p8I+d4LB3hPWGXWLxUly3ko22H2g71QkrqAFgFCWEgnwDv84q3/gpDOP8IlWo/Fzd9JuGVPNX/ZnKsL3+EjcaFp4zLJnwS4fVb6ep8XGGtp0LA9RwbyyWWcnEUoN2U7iGkYQzph/SR6XxZ6hUfiYhhSF7Wjb71MG8H X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(366004)(346002)(136003)(376002)(39840400004)(396003)(451199021)(6916009)(66476007)(66574015)(2616005)(6666004)(6512007)(41300700001)(2906002)(6486002)(83380400001)(478600001)(66556008)(107886003)(52116002)(66946007)(26005)(6506007)(1076003)(186003)(5660300002)(4326008)(316002)(8676002)(8936002)(44832011)(86362001)(38100700002)(36756003)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?V2FubjdjcFhKUGhZNlB2andQQkNraHBDMkxPRHNBSnplWFJ5WmRkVHh3UXdQ?= =?utf-8?B?T2gzNkNnYkpoc3ladTJyanRLUWRxbXJWcDRrd3IzSWp4TVNoUkpwZ1NqUlBP?= =?utf-8?B?U1FtbURCT1EvaGZOeEpVRXBZNklOWEd2eEMvSitXN0pZTDRCc1NLR2FpR2ha?= =?utf-8?B?andJei8xQmhRL05VajNyajBob3RzT002N3FIOUd2YWRUYU85NXo4eVkzbXRU?= =?utf-8?B?TmRrNmp6Zk43Sy9PSUZaWU9JK0lqb3cvT0lvS0NJNkFJZkU5bWJ3a1F6cGRM?= =?utf-8?B?amhmemJnb2kyaHJqL05qZ0JvbUgwYlVOajBzREVQbGM5Rjdpc3R3MHB3aThv?= =?utf-8?B?TjhybklweE5LNmJEenpQM0pWNkg0ZFNvWTF5bVUwSE5xTGtWQmU3TnFtZ2FY?= =?utf-8?B?V2dSTjdkeStOMVNqSzVEbDFta21wejVJTmd3S1lXODQ4eHMyR3F2bk1HcW1F?= =?utf-8?B?cDczMVJpbHlFaGpsRHlVeDkrZ05oQVd5T0daZ2pkdllRZkthQ2luUGVtNE41?= =?utf-8?B?akFYWkpLRlhYTGZRcE90YS9QeEkwSFlHT2poY1RDZzBVOXVqZ09KVVdoRnE0?= =?utf-8?B?SEJlZmFGN0lmNkxQaGFEUVZ5ZDNia3FUa2NFaHlSVWpobTNWVnFBS3FPanVO?= =?utf-8?B?YzZpZUV1WVEwWTczbnNWNWRYNm9keEhneFNFSTA5R1U2dXhnaFJmc2h1czJz?= =?utf-8?B?SGxCcmh2UUtBRUFralRUcnZ4bVd3STV6V3k1WmlNVm5NeUpKbVNGSFpIMGww?= =?utf-8?B?ZkFwVkxrTUZqWU5xd3R6Y1hGSDdOa29ZQWtpM283MERBeFBsNXdpb0NCNzlQ?= =?utf-8?B?RVYvdWo0R3lUMkJDYkJnR2srNFZZYW1vZHNuczJZaFZ5Unp1dUJFeExnbDJ1?= =?utf-8?B?aDYycTVlZUdPeFBaWmFFeWJLZWt1L05QSW1yN1p0MkZqeUQxOFFQUEtEdW50?= =?utf-8?B?MUZVMEswODZsb1k1cnRaUUMyQ1kvTFdpVlJGUUU5dFNEMzRIUFVtNXFXaEt1?= =?utf-8?B?RVAvaHg3NitmWm1PYjdYTW4xYXBUclpwMkw1ajcwOEFCY0lGNHVha2tva2tR?= =?utf-8?B?Y0lrNjVldEwzN0ExVlQzOEtzQUtnWTVpcFBhclFsalJBRGpMSE1QS2gzZ0hp?= =?utf-8?B?d21oNFAwYWsxRDZYZFhMRFRSNWFSRzhvYWErdXBkeXBhSEY1WUlsdGVoWnQy?= =?utf-8?B?NnlEMC9pMzNpcFhmT0hya3VMc2dCSy9hMXdZcXBHSnh4UlFqQzh6bHpNWWlL?= =?utf-8?B?cDdSZEUwS0dtdXhxc015bzg4RVdHNTJ5M1RJRDR3dzdSQ0tHb0o1MXYyMSs5?= =?utf-8?B?MEI3c2l5Q2RhbXRaRjFvbkMwVXBUU09ZbmFZL21odVJTTXpzakVFM3FPUkVW?= =?utf-8?B?OUVPUFBGQzFhdjJrdEY5bTFhZElzaTJwM3UrSzhDYnF3WUFlZVR1K21RcTQy?= =?utf-8?B?S3JXWEVPV3NxUGNTKzV2bmtma2I0TWFaUGJ3RGl6UHlIVXYxdFZCQVQwcGtX?= =?utf-8?B?VnZnUmxmcjFUS2xleE5nRnlDOTlVeExnQW80c0xIaTlrdEtMdFJDSG9xcUdS?= =?utf-8?B?UXBGalN0UHdZRUNNNk1qcVpWclhyNWZVTU5tajN0alRUNFpaT0UvaElZTUg3?= =?utf-8?B?NG05SklOTy93UHF3M0QvcTJ0a3hPNTIyMTc3cExySXRZZE9WTlhsa0NRRnUr?= =?utf-8?B?bVRaMGxub2dDVTBVcm9XcVh4SE5sQkh3dTRnUzNveUJYMzUxQS9hckRaeTFE?= =?utf-8?B?TldtdWR5UWV0ZnA0WE9zelh5WkNBUWpnajRYeG82d0xON2FZWjVyaXk4OVM1?= =?utf-8?B?b2hGTEE3OERFTUpzOXJQV3Myd01DR29rSzcyNjMxYmlwVGtPdUVXR1p2bWJu?= =?utf-8?B?QlpmdGJjMnJMSDRxcnRPaGNaRHdFcXQ5ZWcwZzFoZDU0TTMwZStndjBjRTgw?= =?utf-8?B?OHZwRmdVT2oyWXhtNUVGSUhvVVdBY1htWERiTzcrNDdUN0tvZXJWTEdXUWFn?= =?utf-8?B?WEtpTVA4MkYrSk9OZ2IveHMzRW1CUnd4TEc4bVZ0ZFpkam9RSG5XN0U3MW1p?= =?utf-8?B?dHEybnllWFo0ZWxVQktrN1RtQVdiaFJaOGorNm5nT2JYYVovMTRuc1pscGZK?= =?utf-8?B?UjJDaVNaL1gyWFVuWDdSRC9XYnNYYlBDOVF6MGlVSFp5ZS9iSGJFZ2xCT0Ro?= =?utf-8?B?UUE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f936bb3-9104-49ea-1807-08db58153370 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 03:00:28.6003 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: U/rPAcOQLtge7NaMqk3s48j0CVy6n18KaPHk72b0Hy3e569ufnGPGdIuSKLLIN2l6YEY+G4n+UOqw9oN7fH3qZrYcf9/Xty/GNdUac7sQAA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR13MB5769 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Drop the usage of customed macro and function about MAC address, using the macro and function from framework. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- .../net/nfp/flower/nfp_flower_representor.c | 3 +-- drivers/net/nfp/nfp_common.c | 11 ----------- drivers/net/nfp/nfp_common.h | 4 +--- drivers/net/nfp/nfp_ethdev.c | 17 +++++++---------- drivers/net/nfp/nfp_ethdev_vf.c | 18 ++++++++---------- drivers/net/nfp/nfp_flow.c | 6 +++--- drivers/net/nfp/nfpcore/nfp_nsp.h | 4 +--- drivers/net/nfp/nfpcore/nfp_nsp_eth.c | 8 ++++---- 8 files changed, 25 insertions(+), 46 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c index 86b7d1a220..c3764b4de7 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.c +++ b/drivers/net/nfp/flower/nfp_flower_representor.c @@ -768,8 +768,7 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower) flower_repr.vf_id = i + 1; /* Copy the real mac of the interface to the representor struct */ - rte_ether_addr_copy((struct rte_ether_addr *)eth_port->mac_addr, - &flower_repr.mac_addr); + rte_ether_addr_copy(ð_port->mac_addr, &flower_repr.mac_addr); sprintf(flower_repr.name, "flower_repr_p%d", i); /* diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c index b7a7296999..c9fea765a4 100644 --- a/drivers/net/nfp/nfp_common.c +++ b/drivers/net/nfp/nfp_common.c @@ -453,17 +453,6 @@ nfp_net_cfg_queue_setup(struct nfp_net_hw *hw) hw->qcp_cfg = hw->tx_bar + NFP_QCP_QUEUE_ADDR_SZ; } -#define ETH_ADDR_LEN 6 - -void -nfp_eth_copy_mac(uint8_t *dst, const uint8_t *src) -{ - int i; - - for (i = 0; i < ETH_ADDR_LEN; i++) - dst[i] = src[i]; -} - void nfp_net_write_mac(struct nfp_net_hw *hw, uint8_t *mac) { diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h index 914903f587..47df0510c5 100644 --- a/drivers/net/nfp/nfp_common.h +++ b/drivers/net/nfp/nfp_common.h @@ -232,7 +232,7 @@ struct nfp_net_hw { #endif #endif - uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; + struct rte_ether_addr mac_addr; /* Records starting point for counters */ struct rte_eth_stats eth_stats_base; @@ -428,7 +428,6 @@ void nfp_net_log_device_information(const struct nfp_net_hw *hw); void nfp_net_enable_queues(struct rte_eth_dev *dev); void nfp_net_disable_queues(struct rte_eth_dev *dev); void nfp_net_params_setup(struct nfp_net_hw *hw); -void nfp_eth_copy_mac(uint8_t *dst, const uint8_t *src); void nfp_net_write_mac(struct nfp_net_hw *hw, uint8_t *mac); int nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr); int nfp_configure_rx_interrupt(struct rte_eth_dev *dev, @@ -463,7 +462,6 @@ int nfp_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id); int nfp_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id); void nfp_net_params_setup(struct nfp_net_hw *hw); void nfp_net_cfg_queue_setup(struct nfp_net_hw *hw); -void nfp_eth_copy_mac(uint8_t *dst, const uint8_t *src); void nfp_net_dev_interrupt_handler(void *param); void nfp_net_dev_interrupt_delayed_handler(void *param); int nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 06146050ff..722ec17dce 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -45,8 +45,7 @@ nfp_net_pf_read_mac(struct nfp_app_fw_nic *app_fw_nic, int port) nfp_eth_table = nfp_eth_read_ports(app_fw_nic->pf_dev->cpp); - nfp_eth_copy_mac((uint8_t *)&hw->mac_addr, - (uint8_t *)&nfp_eth_table->ports[port].mac_addr); + rte_ether_addr_copy(&nfp_eth_table->ports[port].mac_addr, &hw->mac_addr); free(nfp_eth_table); return 0; @@ -654,19 +653,18 @@ nfp_net_init(struct rte_eth_dev *eth_dev) } nfp_net_pf_read_mac(app_fw_nic, port); - nfp_net_write_mac(hw, (uint8_t *)&hw->mac_addr); + nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]); - tmp_ether_addr = (struct rte_ether_addr *)&hw->mac_addr; + tmp_ether_addr = &hw->mac_addr; if (!rte_is_valid_assigned_ether_addr(tmp_ether_addr)) { PMD_INIT_LOG(INFO, "Using random mac address for port %d", port); /* Using random mac addresses for VFs */ - rte_eth_random_addr(&hw->mac_addr[0]); - nfp_net_write_mac(hw, (uint8_t *)&hw->mac_addr); + rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]); + nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]); } /* Copying mac address to DPDK eth_dev struct */ - rte_ether_addr_copy((struct rte_ether_addr *)hw->mac_addr, - ð_dev->data->mac_addrs[0]); + rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs); if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR; @@ -677,8 +675,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev) "mac=" RTE_ETHER_ADDR_PRT_FMT, eth_dev->data->port_id, pci_dev->id.vendor_id, pci_dev->id.device_id, - hw->mac_addr[0], hw->mac_addr[1], hw->mac_addr[2], - hw->mac_addr[3], hw->mac_addr[4], hw->mac_addr[5]); + RTE_ETHER_ADDR_BYTES(&hw->mac_addr)); /* Registering LSC interrupt handler */ rte_intr_callback_register(pci_dev->intr_handle, diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index bac8df6142..ce55e3b728 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -23,10 +23,10 @@ nfp_netvf_read_mac(struct nfp_net_hw *hw) uint32_t tmp; tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR)); - memcpy(&hw->mac_addr[0], &tmp, 4); + memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4); tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4)); - memcpy(&hw->mac_addr[4], &tmp, 2); + memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2); } static int @@ -406,18 +406,17 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) nfp_netvf_read_mac(hw); - tmp_ether_addr = (struct rte_ether_addr *)&hw->mac_addr; + tmp_ether_addr = &hw->mac_addr; if (!rte_is_valid_assigned_ether_addr(tmp_ether_addr)) { PMD_INIT_LOG(INFO, "Using random mac address for port %d", port); /* Using random mac addresses for VFs */ - rte_eth_random_addr(&hw->mac_addr[0]); - nfp_net_write_mac(hw, (uint8_t *)&hw->mac_addr); + rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]); + nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]); } /* Copying mac address to DPDK eth_dev struct */ - rte_ether_addr_copy((struct rte_ether_addr *)hw->mac_addr, - ð_dev->data->mac_addrs[0]); + rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs); if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR; @@ -425,11 +424,10 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; PMD_INIT_LOG(INFO, "port %d VendorID=0x%x DeviceID=0x%x " - "mac=%02x:%02x:%02x:%02x:%02x:%02x", + "mac=" RTE_ETHER_ADDR_PRT_FMT, eth_dev->data->port_id, pci_dev->id.vendor_id, pci_dev->id.device_id, - hw->mac_addr[0], hw->mac_addr[1], hw->mac_addr[2], - hw->mac_addr[3], hw->mac_addr[4], hw->mac_addr[5]); + RTE_ETHER_ADDR_BYTES(&hw->mac_addr)); if (rte_eal_process_type() == RTE_PROC_PRIMARY) { /* Registering LSC interrupt handler */ diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c index b46acf6a39..cb7073f361 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -85,7 +85,7 @@ struct nfp_mask_id_entry { struct nfp_pre_tun_entry { uint16_t mac_index; uint16_t ref_cnt; - uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; + struct rte_ether_addr mac_addr; } __rte_aligned(32); static inline struct nfp_flow_priv * @@ -2894,7 +2894,7 @@ nfp_pre_tun_table_check_add(struct nfp_flower_representor *repr, } entry->ref_cnt = 1U; - memcpy(entry->mac_addr, repr->mac_addr.addr_bytes, RTE_ETHER_ADDR_LEN); + rte_ether_addr_copy(&repr->mac_addr, &entry->mac_addr); /* 0 is considered a failed match */ for (i = 1; i < NFP_TUN_PRE_TUN_RULE_LIMIT; i++) { @@ -2954,7 +2954,7 @@ nfp_pre_tun_table_check_del(struct nfp_flower_representor *repr, } entry->ref_cnt = 1U; - memcpy(entry->mac_addr, repr->mac_addr.addr_bytes, RTE_ETHER_ADDR_LEN); + rte_ether_addr_copy(&repr->mac_addr, &entry->mac_addr); /* 0 is considered a failed match */ for (i = 1; i < NFP_TUN_PRE_TUN_RULE_LIMIT; i++) { diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.h b/drivers/net/nfp/nfpcore/nfp_nsp.h index 50cdec3a58..9905b2d3d3 100644 --- a/drivers/net/nfp/nfpcore/nfp_nsp.h +++ b/drivers/net/nfp/nfpcore/nfp_nsp.h @@ -157,8 +157,6 @@ enum nfp_eth_fec { #define NFP_FEC_REED_SOLOMON RTE_BIT32(NFP_FEC_REED_SOLOMON_BIT) #define NFP_FEC_DISABLED RTE_BIT32(NFP_FEC_DISABLED_BIT) -#define ETH_ALEN 6 - /** * struct nfp_eth_table - ETH table information * @count: number of table entries @@ -205,7 +203,7 @@ struct nfp_eth_table { enum nfp_eth_fec fec; enum nfp_eth_aneg aneg; - uint8_t mac_addr[ETH_ALEN]; + struct rte_ether_addr mac_addr; uint8_t label_port; uint8_t label_subport; diff --git a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c index f8d1416d4b..01b4652280 100644 --- a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c +++ b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c @@ -115,7 +115,7 @@ union eth_table_entry { struct { uint64_t port; uint64_t state; - uint8_t mac_addr[6]; + uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; uint8_t resv[2]; uint64_t control; }; @@ -163,8 +163,8 @@ nfp_eth_copy_mac_reverse(uint8_t *dst, const uint8_t *src) { int i; - for (i = 0; i < (int)ETH_ALEN; i++) - dst[ETH_ALEN - i - 1] = src[i]; + for (i = 0; i < RTE_ETHER_ADDR_LEN; i++) + dst[RTE_ETHER_ADDR_LEN - i - 1] = src[i]; } static void @@ -194,7 +194,7 @@ nfp_eth_port_translate(struct nfp_nsp *nsp, const union eth_table_entry *src, dst->interface = FIELD_GET(NSP_ETH_STATE_INTERFACE, state); dst->media = FIELD_GET(NSP_ETH_STATE_MEDIA, state); - nfp_eth_copy_mac_reverse(dst->mac_addr, src->mac_addr); + nfp_eth_copy_mac_reverse(&dst->mac_addr.addr_bytes[0], src->mac_addr); dst->label_port = FIELD_GET(NSP_ETH_PORT_PHYLABEL, port); dst->label_subport = FIELD_GET(NSP_ETH_PORT_LABEL, port); -- 2.39.1