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 B4379424F4; Tue, 5 Sep 2023 18:56:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8033140E03; Tue, 5 Sep 2023 18:56:10 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by mails.dpdk.org (Postfix) with ESMTP id 38158400D7 for ; Tue, 5 Sep 2023 18:56:08 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CiHHitO/yjWlKzJ0Ez1NCQkGrUklkv7RYHPKrd/71M50pza+iyzquceG9c42MGE6Mj+NC0Zy6/OH1qJAnlEQ1x3fDFA5ZkwQ2RQpJu+Jh+/w4KVaSehdRmbuZqrpgy+86TCvPblQyhv+c5i+xH3Npa2eDPSocFo/q8zX1SWq24lIspf5RDgxLgtMAm8xIwNlfwW8dXSJsVGiHRp8jay/fKCiP5C75uuIEvsX8+XvYfxmU7Qc2avIm8CYu/KWQsQZEXnW7ygSLvKSfq0n4ApG+TLdD+cev77ZTROhIXO0lfxd/vqXoEWkM0IfkhMqyOWP/iYTMffxuoGEfGMPte8n7Q== 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=fk/FPSv5AQDOhTu+R14uBuJ42MwaOqr5Nijb0STJKEw=; b=Lz582kaIqmbPaKjcim1oMvoxyIqj1LmsOi5gE02Ta8AVNF6CrU1NzkykersrX91V8IAxqNXEtMUzN04SsliG/ijI6skCCuoF4Vqf5LmnetsG+4Iu8j8FN4Tzpcx7MAcJUk7leKfUa4zJZjjoPj+8wSK1NuCUOuqJzlOVNpwposXHHqkuWSsfsWV5QMeswGAqoWBZGNkuZ1uc5SKMFFC9ZD5dJYBniolenibHfemJop/FZJmUB18AmXXUIftI2NCoYAtbaicH/lLydqpV2FOnJR3x+eGskgrtCPqyLt+xcJfdWkQWiJbUyQQFFJDoKwJ6evM2R3GfNRcE5z0NDxuQuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fk/FPSv5AQDOhTu+R14uBuJ42MwaOqr5Nijb0STJKEw=; b=TZnkmkIXN9gAyeNyJqWa3iTtOWyM0WVOtu7tMvH1u5z4V1I+Ie/E+jDpMa1828kLnzYooNPOF0Cr1QnZblvUdgy4x0+k5fPbHQqg//vaBe2QwA6zu4BTHwl6Kb9ruCBi76S/HsF4C4/CE35voTuV/kZJzsYdTH8YYCxIwvUoWAU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) by SA1PR12MB6917.namprd12.prod.outlook.com (2603:10b6:806:24c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.33; Tue, 5 Sep 2023 16:56:06 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::49e9:2bf6:7f06:bbbd]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::49e9:2bf6:7f06:bbbd%3]) with mapi id 15.20.6745.030; Tue, 5 Sep 2023 16:56:05 +0000 Message-ID: Date: Tue, 5 Sep 2023 17:56:00 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Content-Language: en-US To: Wenbo Cao Cc: dev@dpdk.org, thomas@monjalon.net, andrew.rybchenko@oktetlabs.ru, yaojun@mucse.com References: <20230901023050.40893-1-caowenbo@mucse.com> <20230901023050.40893-7-caowenbo@mucse.com> From: Ferruh Yigit Subject: Re: [PATCH v6 6/8] net/rnp add port info resource init In-Reply-To: <20230901023050.40893-7-caowenbo@mucse.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO3P265CA0008.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:bb::13) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|SA1PR12MB6917:EE_ X-MS-Office365-Filtering-Correlation-Id: f28ef8e4-3d09-4a0f-ca4c-08dbae30fe9d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VMlqmyn/OzO8bDhAds+czH5SeJJhHhC7W8+Rt95Db67O/FFLOB1fPoTuQYedJ0NJheiHdtmrpbgINcG3mjeUgOGQQGjVKVfFEdamQgWJokr6DarckJSY8xVXy3N9R9PycrvRf86BwjtsVmuVj4m9JmJv3yZqiVfZqOCjoRcNNadJQpE9s5CC7rKComZOMTAzZyZ9TJXzphkq0Zv4zuvfLBJnfQksMAVKP5M6UKhhh0uKzabtEJFknxxBW3wlmAcAzE6vHruUKhgTKH24wDitpjGHAa5JySWBMNaH498nRuKFeyiDvzrovBm9/2c6ycgODCY0VlvKU/krwomJhIor9gtxnmody0BUMrTf+/jo6SyrsHyKkSNfVnf4Z58GnYguaa0Urj8QGwiY1RuWRknvMz8BOxpPfYWFnviAn7G5HKEuiYLlfx8tYmTd0nNOj8kunlIZUtV1Rh32om+JFLREnnDZ3JHjoeDY6dLrA6I9UkHLm7aPvHa+bp8pG+hZ8tGB9YiIWgzh4cNNsUA502+PStAGrhT96iIennyl79XvRB/4kx+XzhBxf/PRTq4mWxbjoJy5XgvTKwA/7/m7IOQI+m9MqNaHkfQKbxlyvjl49RFYc8bJYzUdf7pRGVObU05NMO6P9UvskbKHlo20nyWrOg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB4294.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(39860400002)(396003)(346002)(366004)(376002)(186009)(1800799009)(451199024)(2906002)(38100700002)(36756003)(31696002)(86362001)(4326008)(6666004)(8936002)(8676002)(26005)(5660300002)(44832011)(53546011)(41300700001)(66556008)(66476007)(66946007)(6916009)(6506007)(6512007)(316002)(2616005)(6486002)(83380400001)(478600001)(31686004)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dGxROTlTOE94c0preWFyQnNnM1Q4Ym11ZTgraXA1ZnowS1BEMnBaM1Jma0hQ?= =?utf-8?B?dVEwZnBraW13Unk5R3JtbHE2M21NTUp5SDlqa0dmb0lRczRsTjR1K2NXVkVS?= =?utf-8?B?VFFyNGUrV3d4WHBYV1AwZnNXODg1cDJWRmw1UVo3N3dQZUN3SEhidlpWRWlw?= =?utf-8?B?ZTRrb3VnbS9qbCsrSUhyYmM2dEIrU2VxR0xSdnpsdGpkckUxY0w0ZWJRUjlD?= =?utf-8?B?YXhXSm00dW8zK2xzcmVQMjk4bjNpOFQ0SkhxV1Z1TDZjKzhuOEpHdklLM1BI?= =?utf-8?B?QVZhUVJ2UmdCd1NuY09jbG1meks3Z1FhQ3RNRXdyMW1RTTZGdUZoR1ZsdDZG?= =?utf-8?B?cXYzR2NLRTlwSU1neVBYNVJiVmVw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ef8e4-3d09-4a0f-ca4c-08dbae30fe9d X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2023 16:56:05.8021 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: T98+MKiUQ4/glaUM7Bk4bBzbvS5T00slJNwhRzl629vA50vIXXou2KOKAuMWdXrR X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6917 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 On 9/1/2023 3:30 AM, Wenbo Cao wrote: > Add Api For FW Mac Info, Port Resoucre info init Code > For Different Shape Of Nic > > Signed-off-by: Wenbo Cao <...> > @@ -47,11 +104,53 @@ rnp_init_port_resource(struct rnp_eth_adapter *adapter, > uint8_t p_id) > { > struct rnp_eth_port *port = RNP_DEV_TO_PORT(dev); > + struct rte_pci_device *pci_dev = adapter->pdev; > + struct rnp_hw *hw = &adapter->hw; > > + port->adapt = adapter; > + port->s_mode = adapter->s_mode; > + port->port_stopped = 1; > + port->hw = hw; > port->eth_dev = dev; > - adapter->ports[p_id] = port; > + > + dev->device = &pci_dev->device; > + rte_eth_copy_pci_info(dev, pci_dev); > dev->dev_ops = &rnp_eth_dev_ops; > - RTE_SET_USED(name); > + dev->rx_queue_count = rnp_dev_rx_queue_count; > + dev->rx_descriptor_status = rnp_dev_rx_descriptor_status; > + dev->tx_descriptor_status = rnp_dev_tx_descriptor_status; > + dev->rx_pkt_burst = rnp_recv_pkts; > + dev->tx_pkt_burst = rnp_xmit_pkts; > + dev->tx_pkt_prepare = rnp_prep_pkts; > + > + rnp_setup_port_attr(port, dev, adapter->num_ports, p_id); > + rnp_init_filter_setup(port, adapter->num_ports); > + rnp_get_mac_addr(dev, port->mac_addr); > + dev->data->mac_addrs = rte_zmalloc(name, sizeof(struct rte_ether_addr) * > + port->attr.max_mac_addrs, 0); > + if (!dev->data->mac_addrs) { > + RNP_PMD_DRV_LOG(ERR, "Memory allocation " > + "for MAC failed! Exiting.\n"); > + return -ENOMEM; > + } > + /* Allocate memory for storing hash filter MAC addresses */ > + dev->data->hash_mac_addrs = rte_zmalloc(name, > + RTE_ETHER_ADDR_LEN * port->attr.max_uc_mac_hash, 0); > + if (dev->data->hash_mac_addrs == NULL) { > + RNP_PMD_INIT_LOG(ERR, "Failed to allocate %d bytes " > + "needed to store MAC addresses", > + RTE_ETHER_ADDR_LEN * port->attr.max_uc_mac_hash); > + return -ENOMEM; Should free 'dev->data->mac_addrs' here, or even better can be to implement 'rnp_dev_close()' to free device resources. > + } > + > + rnp_set_default_mac(dev, port->mac_addr); I guess the 'port->mac_addr' got from device via 'rnp_get_mac_addr()' above, but if 'rnp_get_mac_addr()' fails what will be the value. Should there be check and set a random mac if required? > + rte_ether_addr_copy((const struct rte_ether_addr *)port->mac_addr, > + dev->data->mac_addrs); > + /* MTU */ > + dev->data->mtu = RTE_ETHER_MAX_LEN - > + RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN; > + adapter->ports[p_id] = port; > + rte_eth_dev_probing_finish(dev); > rte_eth_dev_probing_finish() is not required, as 'rte_eth_dev_pci_generic_probe()' calls it if dev_init() returns success. <...> > +static int32_t rnp_get_mac_addr_pf(struct rnp_eth_port *port, > + uint8_t lane, > + uint8_t *macaddr) > +{ > + struct rnp_hw *hw = RNP_DEV_TO_HW(port->eth_dev); > + > + return rnp_fw_get_macaddr(port->eth_dev, hw->pf_vf_num, macaddr, lane); > +} > + These are mac_ops functions, normally the reason to have mac_ops is to support different HW that behaves slightly different and this difference managed by different function pointers per device. Is this your usecase? And since these are mac_ops, defined in the base folder header, it suits better to have separate .c file for them which is under base file, what do you think? Or am I getting these mac_ops wrong? > +static int32_t > +rnp_set_default_mac_pf(struct rnp_eth_port *port, > + uint8_t *mac) > +{ > + struct rnp_eth_adapter *adap = RNP_PORT_TO_ADAPTER(port); > + uint16_t max_vfs; > + > + if (port->s_mode == RNP_SHARE_INDEPENDENT) > + return rnp_set_rafb(port->eth_dev, (uint8_t *)mac, > + UINT8_MAX, 0); > + > + max_vfs = adap->max_vfs; > + > + return rnp_set_rafb(port->eth_dev, mac, max_vfs, 0); > +} > + > const struct rnp_mac_api rnp_mac_ops = { > .reset_hw = rnp_reset_hw_pf, > - .init_hw = rnp_init_hw_pf > + .init_hw = rnp_init_hw_pf, > + .get_mac_addr = rnp_get_mac_addr_pf, > + .set_default_mac = rnp_set_default_mac_pf, > + .set_rafb = rnp_set_mac_addr_pf, > + .clear_rafb = rnp_clear_mac_addr_pf > }; > > static void > @@ -228,7 +434,11 @@ rnp_common_ops_init(struct rnp_eth_adapter *adapter) > static int > rnp_special_ops_init(struct rte_eth_dev *eth_dev) > { > - RTE_SET_USED(eth_dev); > + struct rnp_eth_adapter *adapter = RNP_DEV_TO_ADAPTER(eth_dev); > + struct rnp_share_ops *share_priv; > + > + share_priv = adapter->share_priv; > + share_priv->mac_api = &rnp_mac_ops; > Can you please describe why this 'rnp_special_ops_init()' is for (its difference from rnp_common_ops_init()) ?