From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80083.outbound.protection.outlook.com [40.107.8.83]) by dpdk.org (Postfix) with ESMTP id 2756E4C91 for ; Thu, 28 Feb 2019 16:49:29 +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=9WVxZ4r0Q9flE8hWE+TO8X+bUVPEVeGJyh5uABy7wa4=; b=k3H4CXqpg66MouVEJmgf8FQ8zoAVCWJceRmur4DNRl2wg+x+5g6KYp9k0fEFPzyC7e+tHuUXekUqFVWIcPf71N9hhGMhN/oSEA/wu/1q7Mwv3jg1TqJT8IUBJt3T0+VLjiPMpZ28gr488Z+VVHsD/TjgYCaNG+GlyKRgqKGcMGQ= Received: from AM6PR05MB5926.eurprd05.prod.outlook.com (20.179.2.27) by AM6PR05MB5458.eurprd05.prod.outlook.com (20.177.118.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.16; Thu, 28 Feb 2019 15:49:27 +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.1643.022; Thu, 28 Feb 2019 15:49:27 +0000 From: Raslan Darawsheh To: "gaetan.rivet@6wind.com" CC: "dev@dpdk.org" , Thomas Monjalon , Raslan Darawsheh Thread-Topic: [PATCH 3/4] net/failsafe: replace local sub-device with shared data Thread-Index: AQHUz30v78A8mrY2HEqbgkhSSjO7QA== Date: Thu, 28 Feb 2019 15:49:27 +0000 Message-ID: <1551368952-1871-4-git-send-email-rasland@mellanox.com> References: <1551368952-1871-1-git-send-email-rasland@mellanox.com> In-Reply-To: <1551368952-1871-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: LO2P265CA0431.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a0::35) 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: 5c1c6f4d-128b-48e4-2b07-08d69d9451f2 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:AM6PR05MB5458; x-ms-traffictypediagnostic: AM6PR05MB5458: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; AM6PR05MB5458; 23:/Y4TLgm2Nl+oqri2YOI24S/R8U6FG4seG+uwDmB?= =?iso-8859-1?Q?yAvJWkd/nvgU59MXC2sU+wmza0Uz87fW855eCOtfSCjun/jNhBaD8KEQ/R?= =?iso-8859-1?Q?C5h1IILmSPWK3IDfS5euDRkPN2QbzQDyJyBzGFLkNKQ4htOGIBX1i3/qb0?= =?iso-8859-1?Q?RkZ8HiiuD1sGKE0JY2pLcim+9MJTWgqinojJmnC/28b5kqOHH2JzJEhWPL?= =?iso-8859-1?Q?6bgK0XazgLRzRC/+ppWQcRBoK1cScQlbovrbalDquLeApQwsAlVBllcfYp?= =?iso-8859-1?Q?2uFemcAASKxVVM+J+IGp5SOaZGjqP1ZqFvBB/tGdPju+jOpEBP6JHNGxak?= =?iso-8859-1?Q?Y6vKxR9fiBB16NF5zT3KSQzuyKVeM0IEGoHtkhdHX9FjkCx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gPWZLUeGZk9vMitS6bhHeuVdLcC5U2bNubyW9AIWxazh18+hRIfW?= =?iso-8859-1?Q?EC2VvSLRw3uSnqfAK5mDAABfJY/OQuuxG40kN16Vd2YJg=3D=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0962D394D2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(346002)(136003)(39860400002)(366004)(376002)(189003)(199004)(6116002)(3846002)(71200400001)(71190400001)(54906003)(25786009)(476003)(36756003)(478600001)(14454004)(2616005)(5660300002)(7736002)(305945005)(486006)(97736004)(6916009)(446003)(11346002)(50226002)(102836004)(8936002)(76176011)(52116002)(107886003)(81166006)(81156014)(8676002)(68736007)(186003)(386003)(2906002)(2501003)(6506007)(316002)(99286004)(53936002)(6436002)(6486002)(5640700003)(106356001)(2351001)(14444005)(256004)(66066001)(26005)(4326008)(6512007)(86362001)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR05MB5458; 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: ZnOVVUnTP8PZpfABJYEdpE03Jp2krD+6KO5Ozzq4d7Q3v09AHK5HNkQi5wrWbOdYoArWeYprQTVhZfPc8H3XdV4PuKBcx1WuUBb5H8VgE8Tpyb70HV8PfMougjeLnIOhHCzdH0lITEIFapBS3fHFddfR1Tzp0BydwSfUP8UhjE9Dd2T5jHW5KnuQgqsnE87WX8k1lfHrq/BOK+nEyzSfLK/IfpFMVfWpEbcMllnUGKYg4KI+4USqCBi6y5arTmLOpT0rYn27ILrDs2yzJq3WZGT+CBV46JZaCbx9q6cdL97L5o+coetU3PQzip1GW1Nk3Gjszeid94u8oUHsi3IHlX5yNjjKhrMMAadOLhVd+UM/pyxFO3pBNVOktE4bASD3gqrlWELC2z5ZZbMXlsoJ8h5Ibx9EXUNcR6yxB9oULE8= 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: 5c1c6f4d-128b-48e4-2b07-08d69d9451f2 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2019 15:49:27.0566 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB5458 Subject: [dpdk-dev] [PATCH 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: Thu, 28 Feb 2019 15:49:29 -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 --- drivers/net/failsafe/failsafe_eal.c | 2 +- drivers/net/failsafe/failsafe_ether.c | 7 ++++--- drivers/net/failsafe/failsafe_private.h | 11 +++++++---- 3 files changed, 12 insertions(+), 8 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 8d958e0..9b9753f 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 9b53a19..60ee0a7 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; @@ -257,7 +260,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