From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20076.outbound.protection.outlook.com [40.107.2.76]) by dpdk.org (Postfix) with ESMTP id 94C8F3238 for ; Mon, 9 Jul 2018 09:47:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OCXFjgPw6IeZzP/f8H/+Wli9uYImrWsRQYAKpXG2CgI=; b=iB3ubb2OVLoxtbOo5CV6ieM13NUB5sqv44mVfQi9F8k90wkSdB7QcoldEi+psDlvl4dL+w3Kjtj/M5PYCLwGV84SHNnby2EIWAjAMgd/ysN+3VC4uR90gSSP9Sl8/8ip15x9a4M1CX4AbYiav+HMr6QVazI0valp1yY5mqsmDtA= Received: from VI1PR0501MB2608.eurprd05.prod.outlook.com (10.168.137.20) by VI1PR0501MB2191.eurprd05.prod.outlook.com (10.169.134.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.19; Mon, 9 Jul 2018 07:47:38 +0000 Received: from VI1PR0501MB2608.eurprd05.prod.outlook.com ([fe80::9dd0:9bdb:fd59:b615]) by VI1PR0501MB2608.eurprd05.prod.outlook.com ([fe80::9dd0:9bdb:fd59:b615%7]) with mapi id 15.20.0930.022; Mon, 9 Jul 2018 07:47:37 +0000 From: Matan Azrad To: Jeff Guo , "stephen@networkplumber.org" , "bruce.richardson@intel.com" , "ferruh.yigit@intel.com" , "konstantin.ananyev@intel.com" , "gaetan.rivet@6wind.com" , "jingjing.wu@intel.com" , Thomas Monjalon , Mordechay Haimovsky , "harry.van.haaren@intel.com" , "qi.z.zhang@intel.com" , "shaopeng.he@intel.com" , "bernard.iremonger@intel.com" , "arybchenko@solarflare.com" CC: "jblunck@infradead.org" , "shreyansh.jain@nxp.com" , "dev@dpdk.org" , "helin.zhang@intel.com" Thread-Topic: [PATCH v2 2/3] net/i40e: enable hotplug detect in i40e Thread-Index: AQHUF1Jf52yAxJ+VjEKMLrxW5BvnWaSGgeBA Date: Mon, 9 Jul 2018 07:47:37 +0000 Message-ID: References: <1530787185-5915-1-git-send-email-jia.guo@intel.com> <1531119413-17298-1-git-send-email-jia.guo@intel.com> <1531119413-17298-3-git-send-email-jia.guo@intel.com> In-Reply-To: <1531119413-17298-3-git-send-email-jia.guo@intel.com> Accept-Language: en-US, he-IL Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0501MB2191; 7:rq+QZ/DJDoX0WMhhm5xAesEG63F6ecm7iXfy3l18TGzYFZw2F2fTTFGDBzDYQWMpvFmtA5rgF9CIt7ry1iWVA7MeEHNwiKowh/BPcgOuS8KZb+yxRDf03XwdF0IR4RZysVNHkx+awJLw20CmGMmxzn9ZKI8x6AYxrJz+Eaq1pO8NIEnWDSWbRJBltSQTutbV2SLocZ/CS7MwiyPHdIyKN2eZ1SEYwY3WWZotSdinSjmFXoLZNxrCkVLdsw1zWz4K x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 02aca866-8af5-4332-2dac-08d5e5703ddf x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(48565401081)(2017052603328)(7153060)(7193020); SRVR:VI1PR0501MB2191; x-ms-traffictypediagnostic: VI1PR0501MB2191: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3002001)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:VI1PR0501MB2191; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0501MB2191; x-forefront-prvs: 07283408BE x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(396003)(346002)(136003)(366004)(199004)(189003)(76176011)(305945005)(7736002)(4326008)(54906003)(7416002)(25786009)(102836004)(106356001)(186003)(26005)(6506007)(110136005)(53936002)(33656002)(105586002)(7696005)(3846002)(6246003)(316002)(2501003)(9686003)(74316002)(5250100002)(6116002)(55016002)(2900100001)(99286004)(8936002)(86362001)(6436002)(11346002)(97736004)(14444005)(446003)(81156014)(478600001)(2906002)(81166006)(229853002)(8676002)(66066001)(5660300001)(68736007)(256004)(14454004)(486006)(476003)(2201001)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2191; H:VI1PR0501MB2608.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: RCJ8bz+xIH+4sIJQpLc5ZRKWfWIktSs+lKjQ4efpOLqTLDcT3nbj+T0VvfSJnkjIIPgyt5W7el2xbrFrqWa/4Gz5sPPnn9nO0uGvnOD5kRPZElTc1+5ELgcxy+uRAGc22zMuWDIqWrFbT2gWO2ggXM162DxYqL1erVQACJ2/NmGL8ItuwP5d1g2maI1Owi4L+jwTMmUdSzvF/jV6tOQ0eJcWmgR70NTrnJPUMcy3ghTr3we6pIrpbMweaW5F1ZrLIqetgOiylf1SAQeBbuY4DM1pP1ViXtqbwsGp27031nit5gv5sKQXcipGMqUBNr6RyBm9fsduuBQkb7VtuYK+Lt5VBnteHYMr4RErjkwEhIg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 02aca866-8af5-4332-2dac-08d5e5703ddf X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jul 2018 07:47:37.8866 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2191 Subject: Re: [dpdk-dev] [PATCH v2 2/3] net/i40e: enable hotplug detect in i40e 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, 09 Jul 2018 07:47:40 -0000 Hi Guo From: Jeff Guo > This patch aim to enable hotplug detect in i40e pmd driver. Firstly it se= t the > flags RTE_PCI_DRV_INTR_RMV in drv_flags to announce the hotplug ability, > and then use rte_dev_event_callback_register to register the hotplug even= t > callback to eal. When eal detect the hotplug event, it will call the call= back to > process it, if the event is hotplug remove, it will trigger the > RTE_ETH_EVENT_INTR_RMV event into ethdev callback to let app process > the hotplug for the ethdev. >=20 > This is an example for other driver, that if any driver support hotplug f= eature > could be use this way to enable hotplug detect. >=20 > Signed-off-by: Jeff Guo > --- > v2->v1: > no v1, add hotplug detect in ixgbe for new. > --- > drivers/net/i40e/i40e_ethdev.c | 46 > +++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 45 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethde= v.c > index 13c5d32..ad4231f 100644 > --- a/drivers/net/i40e/i40e_ethdev.c > +++ b/drivers/net/i40e/i40e_ethdev.c > @@ -688,7 +688,7 @@ static int eth_i40e_pci_remove(struct rte_pci_device > *pci_dev) static struct rte_pci_driver rte_i40e_pmd =3D { > .id_table =3D pci_id_i40e_map, > .drv_flags =3D RTE_PCI_DRV_NEED_MAPPING | > RTE_PCI_DRV_INTR_LSC | > - RTE_PCI_DRV_IOVA_AS_VA, > + RTE_PCI_DRV_IOVA_AS_VA | RTE_PCI_DRV_INTR_RMV, > .probe =3D eth_i40e_pci_probe, > .remove =3D eth_i40e_pci_remove, > }; > @@ -1183,6 +1183,47 @@ i40e_aq_debug_write_global_register(struct > i40e_hw *hw, > return i40e_aq_debug_write_register(hw, reg_addr, reg_val, > cmd_details); } >=20 > +static void > +eth_dev_event_callback(char *device_name, enum rte_dev_event_type > type, > + __rte_unused void *arg) > +{ > + uint32_t pid; > + > + if (type >=3D RTE_DEV_EVENT_MAX) { > + fprintf(stderr, "%s called upon invalid event %d\n", > + __func__, type); > + fflush(stderr); > + } > + > + switch (type) { > + case RTE_DEV_EVENT_REMOVE: > + PMD_DRV_LOG(INFO, "The device: %s has been > removed!\n", > + device_name); > + > + if (!device_name) > + return; > + > + for (pid =3D 0; pid < RTE_MAX_ETHPORTS; pid++) { > + if (rte_eth_devices[pid].device) { > + if (!strcmp(device_name, > + rte_eth_devices[pid].device->name)) { You just need to compare this PMD ethdev ports device names to the current = EAL removed device name. You should not raise RMV events for other PMD ports. > + _rte_eth_dev_callback_process( > + &rte_eth_devices[pid], > + RTE_ETH_EVENT_INTR_RMV, > NULL); > + continue; > + } > + } > + } > + break; > + case RTE_DEV_EVENT_ADD: > + RTE_LOG(INFO, EAL, "The device: %s has been added!\n", > + device_name); > + break; > + default: > + break; > + } > +} > + > static int > eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params > __rte_unused) { @@ -1442,6 +1483,9 @@ eth_i40e_dev_init(struct > rte_eth_dev *dev, void *init_params __rte_unused) > rte_intr_callback_register(intr_handle, > i40e_dev_interrupt_handler, dev); >=20 > + /* register the device event callback */ > + rte_dev_event_callback_register(NULL, eth_dev_event_callback, > NULL); > + > /* configure and enable device interrupt */ > i40e_pf_config_irq0(hw, TRUE); > i40e_pf_enable_irq0(hw); > -- > 2.7.4