From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10084.outbound.protection.outlook.com [40.107.1.84]) by dpdk.org (Postfix) with ESMTP id AFCF227D for ; Tue, 5 Mar 2019 10:52:07 +0100 (CET) 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=/U3iRRKBj1NjL+IHZIakG7mGiFZ9Jk59fWlRLYx7ht4=; b=Rd3u4bq8D/KiLMwZSWNxDX7zymkKMLwaG4HaQ4OW9C/kl0I04UMCFwmY7PdYmE5CQmP+BpXZW1HpLg+kNLkcrsVK23lwuixgMDb1n9rKBOJOW4U9wcwDQGwnY5SO8DptmxFnqQUGz2oKBSNa4pLxlxSAUy4vt14BD9E7NVAWzlY= Received: from AM6PR05MB5926.eurprd05.prod.outlook.com (20.179.2.27) by AM6PR05MB4487.eurprd05.prod.outlook.com (52.135.162.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.18; Tue, 5 Mar 2019 09:52:06 +0000 Received: from AM6PR05MB5926.eurprd05.prod.outlook.com ([fe80::4d49:8512:d097:4a52]) by AM6PR05MB5926.eurprd05.prod.outlook.com ([fe80::4d49:8512:d097:4a52%4]) with mapi id 15.20.1665.020; Tue, 5 Mar 2019 09:52:06 +0000 From: Raslan Darawsheh To: "gaetan.rivet@6wind.com" CC: "dev@dpdk.org" , Thomas Monjalon , Raslan Darawsheh , "stephen@networkplumber.org" Thread-Topic: [PATCH v2 3/4] net/failsafe: replace local sub-device with shared data Thread-Index: AQHU0zkXnxxf40CUoEe2KJZ0xt62sg== Date: Tue, 5 Mar 2019 09:52:05 +0000 Message-ID: <1551779507-10857-3-git-send-email-rasland@mellanox.com> References: <1551779507-10857-1-git-send-email-rasland@mellanox.com> In-Reply-To: <1551779507-10857-1-git-send-email-rasland@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-clientproxiedby: LO2P265CA0426.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a0::30) To AM6PR05MB5926.eurprd05.prod.outlook.com (2603:10a6:20b:a9::27) authentication-results: spf=none (sender IP is ) smtp.mailfrom=rasland@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.13.130] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6c3eb1c4-1fc8-4e74-bb6f-08d6a15039af x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM6PR05MB4487; x-ms-traffictypediagnostic: AM6PR05MB4487: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; AM6PR05MB4487; 23:1BF15DOLmrKoq3G1+S02YMKC3p9ry1kiEhPspj/?= =?iso-8859-1?Q?hDDmW/NZ+hxvGHKfyhmEHmLGWVqzFC1vTuq3xUeDFc1h1DIpFXt07f0IMd?= =?iso-8859-1?Q?LUMHyL7JuzOhZMULbpFnCWjMG1+YLyXTpM0MNjNmsKGX4LMDXSFSR9uzYI?= =?iso-8859-1?Q?yslYTZ0IlLHnw2Vo8WSZ7yo0DawYx2aA/0egILbnYSKWfPxy86pQThBIZX?= =?iso-8859-1?Q?9bORNW1za7EGsIJndWrDQSpFS3tWX+S59dzyRRZ7aNK4FUd8gm5uQ2PHyP?= =?iso-8859-1?Q?zJRfjRyUJ+Im+nCvgtc4t7fSI5VFAdZHpn7vRqxLsePwfl3nfRKykurNoa?= =?iso-8859-1?Q?8QsKSCJSh5vFREBMVcFtKalG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?jawDAv/hbLhx+F4mskupZf7VREjAL9WO7jCNTqaIpYA69lbLa8SF4F/t7z?= =?iso-8859-1?Q?9Z+I+r7uGRZVDcYFatoZWVb?= x-microsoft-antispam-prvs: x-forefront-prvs: 0967749BC1 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(396003)(376002)(366004)(136003)(346002)(189003)(199004)(25786009)(486006)(8936002)(6916009)(3846002)(53936002)(6512007)(52116002)(102836004)(2351001)(2906002)(5660300002)(446003)(2501003)(66066001)(97736004)(478600001)(11346002)(99286004)(305945005)(106356001)(186003)(6486002)(386003)(26005)(14454004)(50226002)(316002)(4326008)(6506007)(68736007)(71190400001)(54906003)(71200400001)(76176011)(105586002)(476003)(5640700003)(7736002)(256004)(36756003)(14444005)(86362001)(6116002)(8676002)(6436002)(2616005)(81166006)(81156014); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR05MB4487; H:AM6PR05MB5926.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: gqGwUjNPZVfvpLptbYGGI4lAfxMKb4OnslNyzUNJDAInZM8T1dosQa8EtULAp8WCfC00Gy8g/ukaOhM0Cigai/+M3whwCY1rHrF9CrO44n0GXEsdYM0vRAL6Qik3jyNVKdwLxNys2ft8+FdaV+I+VKvKfOSFcLiVFMh7SXk9KZgMrtmASX9+6POaGJLIPJqQVPfJzxhx8idHdVD6sbSgU04wqImtXwLFN+FIf3l8gb9yrFUZZqNaH2dBvy+SW4v3bReE7C1e+UkpK0w/nd0dCoPaak5TLp6xPR9f0zV2rVyFJnpXmV+GZHXraZ2zfyePn0O5ZQviIWJtvXcx7gblDWaj5BDbWOM1c/33jO6kmpZrPb3nxkbZMlO2RGA1c8XXz5QhO9FOIGO1lV0PCMA1aaDVvxsk88KsERZLKcJiB4I= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c3eb1c4-1fc8-4e74-bb6f-08d6a15039af X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Mar 2019 09:52:05.9889 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB4487 Subject: [dpdk-dev] [PATCH v2 3/4] net/failsafe: replace local sub-device with shared data 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: Tue, 05 Mar 2019 09:52:07 -0000 In multiprocess context, the pointer to sub-device is shared between processes. Previously, it was a pointer to per process eth_dev so it's needed to replace this dependency. Signed-off-by: Thomas Monjalon Signed-off-by: Raslan Darawsheh --- v2: - moved comment in fs_sdev about subs to this commit - added parenthesis around macro arguments. --- drivers/net/failsafe/failsafe_eal.c | 2 +- drivers/net/failsafe/failsafe_ether.c | 7 ++++--- drivers/net/failsafe/failsafe_private.h | 13 ++++++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/net/failsafe/failsafe_eal.c b/drivers/net/failsafe/fai= lsafe_eal.c index 56d1669..6fac4b6 100644 --- a/drivers/net/failsafe/failsafe_eal.c +++ b/drivers/net/failsafe/failsafe_eal.c @@ -112,7 +112,7 @@ fs_bus_init(struct rte_eth_dev *dev) continue; } } - ETH(sdev) =3D &rte_eth_devices[pid]; + sdev->data =3D rte_eth_devices[pid].data; SUB_ID(sdev) =3D i; sdev->fs_port_id =3D dev->data->port_id; sdev->dev =3D ETH(sdev)->device; diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/f= ailsafe_ether.c index d5b1488..e1fff59 100644 --- a/drivers/net/failsafe/failsafe_ether.c +++ b/drivers/net/failsafe/failsafe_ether.c @@ -267,18 +267,19 @@ static void fs_dev_remove(struct sub_device *sdev) { int ret; + struct rte_eth_dev *edev =3D ETH(sdev); =20 if (sdev =3D=3D NULL) return; switch (sdev->state) { case DEV_STARTED: failsafe_rx_intr_uninstall_subdevice(sdev); - rte_eth_dev_stop(PORT_ID(sdev)); + rte_eth_dev_stop(edev->data->port_id); sdev->state =3D DEV_ACTIVE; /* fallthrough */ case DEV_ACTIVE: failsafe_eth_dev_unregister_callbacks(sdev); - rte_eth_dev_close(PORT_ID(sdev)); + rte_eth_dev_close(edev->data->port_id); sdev->state =3D DEV_PROBED; /* fallthrough */ case DEV_PROBED: @@ -287,7 +288,7 @@ fs_dev_remove(struct sub_device *sdev) ERROR("Bus detach failed for sub_device %u", SUB_ID(sdev)); } else { - rte_eth_dev_release_port(ETH(sdev)); + rte_eth_dev_release_port(edev); } sdev->state =3D DEV_PARSED; /* fallthrough */ diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe= /failsafe_private.h index 84e847f..1e2ad2d 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -100,13 +100,16 @@ struct fs_stats { uint64_t timestamp; }; =20 +/* + * Allocated in shared memory. + */ struct sub_device { /* Exhaustive DPDK device description */ struct sub_device *next; struct rte_devargs devargs; - struct rte_bus *bus; - struct rte_device *dev; - struct rte_eth_dev *edev; + struct rte_bus *bus; /* per process. */ + struct rte_device *dev; /* per process. */ + struct rte_eth_dev_data *data; /* shared between processes */ uint8_t sid; /* Device state machine */ enum dev_state state; @@ -139,7 +142,7 @@ struct fs_priv { * subs[0] is the preferred device * any other is just another slave */ - struct sub_device *subs; + struct sub_device *subs; /* shared between processes */ uint8_t subs_head; /* if head =3D=3D tail, no subs */ uint8_t subs_tail; /* first invalid */ uint8_t subs_tx; /* current emitting device */ @@ -254,7 +257,7 @@ extern int failsafe_mac_from_arg; =20 /* sdev: (struct sub_device *) */ #define ETH(sdev) \ - ((sdev)->edev) + ((sdev)->data =3D=3D NULL ? NULL : &rte_eth_devices[(sdev)->data->port_id= ]) =20 /* sdev: (struct sub_device *) */ #define PORT_ID(sdev) \ --=20 2.7.4