From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50082.outbound.protection.outlook.com [40.107.5.82]) by dpdk.org (Postfix) with ESMTP id BE942378B for ; Mon, 18 Mar 2019 17:05:28 +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=0hmhNFW5FgewvwTKEv5zLy2s+uPR2WClPU1zgtPzNdM=; b=Wofg7t+TRxpSY1s1figrSNgEM08oJbhRSMCkkaxexSIHU2MeqkqA4/17OlAyEQa0zvGINMuUc+uwPvPXI+ZU9e+3qAXzUNI7FydObNwu+WptJyCZqwq3tLWzipWRQ/0DgoYuBpIRTNc8OjdFhsGZQp6uYRnX3OIpLB41WHvH9tM= Received: from AM6PR05MB5926.eurprd05.prod.outlook.com (20.179.2.27) by AM6PR05MB5798.eurprd05.prod.outlook.com (20.178.94.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1709.14; Mon, 18 Mar 2019 16:05:26 +0000 Received: from AM6PR05MB5926.eurprd05.prod.outlook.com ([fe80::ddb7:2093:62c0:59fb]) by AM6PR05MB5926.eurprd05.prod.outlook.com ([fe80::ddb7:2093:62c0:59fb%2]) with mapi id 15.20.1709.015; Mon, 18 Mar 2019 16:05:26 +0000 From: Raslan Darawsheh To: "gaetan.rivet@6wind.com" CC: "dev@dpdk.org" , Thomas Monjalon , Raslan Darawsheh , "stephen@networkplumber.org" Thread-Topic: [PATCH v3 2/4] net/failsafe: change back-reference from sub-device Thread-Index: AQHU3aRmMi7p3R57b0Sk36vulWuvOw== Date: Mon, 18 Mar 2019 16:05:26 +0000 Message-ID: <1552925103-2821-3-git-send-email-rasland@mellanox.com> References: <1551779507-10857-1-git-send-email-rasland@mellanox.com> <1552925103-2821-1-git-send-email-rasland@mellanox.com> In-Reply-To: <1552925103-2821-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: LNXP123CA0003.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:d2::15) 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: 818f0fbb-5f33-4625-a687-08d6abbb8882 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:AM6PR05MB5798; x-ms-traffictypediagnostic: AM6PR05MB5798: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-forefront-prvs: 098076C36C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(136003)(346002)(366004)(396003)(189003)(199004)(68736007)(6486002)(36756003)(316002)(8936002)(50226002)(5640700003)(53936002)(6916009)(6436002)(71200400001)(97736004)(71190400001)(6512007)(256004)(3846002)(14444005)(6116002)(86362001)(66066001)(2906002)(76176011)(52116002)(5660300002)(54906003)(2616005)(386003)(102836004)(81156014)(81166006)(478600001)(26005)(186003)(6506007)(8676002)(305945005)(14454004)(106356001)(4326008)(105586002)(2501003)(11346002)(446003)(2351001)(476003)(7736002)(99286004)(25786009)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR05MB5798; 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: pnKXLBTx8oNWYIH6KdhgfFI1mqFa3Wl5LXKs1we62M80EUyjWlA29jY3l8STWhVvVHyd9BRh5K1wZOxIG9D8cuqRMEys4DuQdGcADfb3cNPvUc9+RZiFVTHDu2aLx+KJP/l+0aY4UTIwDbRKFBSPgxdB0VHLGBsC5sj3DamnBXy0EEyBDe+cTrRiP/gtIJMR+ruHtHDy2Xa9S9my6QPdYRNtRJ1E/KXYj6tuf4jV4rgFhJp3kH9TCms1oJK+VJw0V129h7ASJ+11XZ+bLCeXiVeUMnEwhx2kFVuTLZNC5yhvFfallKdrn1eJqaPEJcCFZWkljSBfOHoh3gIySYn8fqTchwWUFYVRIL2MnysfIg1mBkWEJOdU3tbrYqiVyG0+MujX4+IkaSdn49BIb57e/wRTpvG387sWc9Fk+AvsESs= 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: 818f0fbb-5f33-4625-a687-08d6abbb8882 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2019 16:05:26.1004 (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: AM6PR05MB5798 Subject: [dpdk-dev] [PATCH v3 2/4] net/failsafe: change back-reference from sub-device 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, 18 Mar 2019 16:05:29 -0000 In multiprocess context, the sub-device structure is shared between processes. The reference to the failsafe device was a per process pointer. It's changed to port id which is the same for all processes. Signed-off-by: Raslan Darawsheh Signed-off-by: Thomas Monjalon --- v2: changed macro to an inline function v3: changed prefix of inline function. =20 --- drivers/net/failsafe/failsafe_eal.c | 2 +- drivers/net/failsafe/failsafe_ether.c | 15 ++++++++------- drivers/net/failsafe/failsafe_intr.c | 10 +++++----- drivers/net/failsafe/failsafe_private.h | 15 ++++++++++----- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/drivers/net/failsafe/failsafe_eal.c b/drivers/net/failsafe/fai= lsafe_eal.c index 8a888b1..56d1669 100644 --- a/drivers/net/failsafe/failsafe_eal.c +++ b/drivers/net/failsafe/failsafe_eal.c @@ -114,7 +114,7 @@ fs_bus_init(struct rte_eth_dev *dev) } ETH(sdev) =3D &rte_eth_devices[pid]; SUB_ID(sdev) =3D i; - sdev->fs_dev =3D dev; + sdev->fs_port_id =3D dev->data->port_id; sdev->dev =3D ETH(sdev)->device; sdev->state =3D DEV_PROBED; } diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/f= ailsafe_ether.c index 1783165..7fa209a 100644 --- a/drivers/net/failsafe/failsafe_ether.c +++ b/drivers/net/failsafe/failsafe_ether.c @@ -298,7 +298,7 @@ fs_dev_remove(struct sub_device *sdev) break; } sdev->remove =3D 0; - failsafe_hotplug_alarm_install(sdev->fs_dev); + failsafe_hotplug_alarm_install(fs_dev(sdev)); } =20 static void @@ -318,8 +318,9 @@ fs_dev_stats_save(struct sub_device *sdev) WARN("Using latest snapshot taken before %"PRIu64" seconds.\n", (rte_rdtsc() - timestamp) / rte_get_tsc_hz()); } - failsafe_stats_increment(&PRIV(sdev->fs_dev)->stats_accumulator, - err ? &sdev->stats_snapshot.stats : &stats); + failsafe_stats_increment + (&PRIV(fs_dev(sdev))->stats_accumulator, + err ? &sdev->stats_snapshot.stats : &stats); memset(&sdev->stats_snapshot, 0, sizeof(sdev->stats_snapshot)); } =20 @@ -566,17 +567,17 @@ failsafe_eth_rmv_event_callback(uint16_t port_id __rt= e_unused, { struct sub_device *sdev =3D cb_arg; =20 - fs_lock(sdev->fs_dev, 0); + fs_lock(fs_dev(sdev), 0); /* Switch as soon as possible tx_dev. */ - fs_switch_dev(sdev->fs_dev, sdev); + fs_switch_dev(fs_dev(sdev), sdev); /* Use safe bursts in any case. */ - failsafe_set_burst_fn(sdev->fs_dev, 1); + failsafe_set_burst_fn(fs_dev(sdev), 1); /* * Async removal, the sub-PMD will try to unregister * the callback at the source of the current thread context. */ sdev->remove =3D 1; - fs_unlock(sdev->fs_dev, 0); + fs_unlock(fs_dev(sdev), 0); return 0; } =20 diff --git a/drivers/net/failsafe/failsafe_intr.c b/drivers/net/failsafe/fa= ilsafe_intr.c index 09aa3c6..0f34c5b 100644 --- a/drivers/net/failsafe/failsafe_intr.c +++ b/drivers/net/failsafe/failsafe_intr.c @@ -274,14 +274,14 @@ failsafe_eth_rx_intr_ctl_subdevice(struct sub_device = *sdev, int op) int rc; int ret =3D 0; =20 + fsdev =3D fs_dev(sdev); if (sdev =3D=3D NULL || (ETH(sdev) =3D=3D NULL) || - sdev->fs_dev =3D=3D NULL || (PRIV(sdev->fs_dev) =3D=3D NULL)) { + fsdev =3D=3D NULL || (PRIV(fsdev) =3D=3D NULL)) { ERROR("Called with invalid arguments"); return -EINVAL; } dev =3D ETH(sdev); - fsdev =3D sdev->fs_dev; - epfd =3D PRIV(sdev->fs_dev)->rxp.efd; + epfd =3D PRIV(fsdev)->rxp.efd; pid =3D PORT_ID(sdev); =20 if (epfd <=3D 0) { @@ -330,7 +330,7 @@ int failsafe_rx_intr_install_subdevice(struct sub_devic= e *sdev) const struct rte_intr_conf *const intr_conf =3D Ð(sdev)->data->dev_conf.intr_conf; =20 - fsdev =3D sdev->fs_dev; + fsdev =3D fs_dev(sdev); rxq =3D (struct rxq **)fsdev->data->rx_queues; if (intr_conf->rxq =3D=3D 0) return 0; @@ -368,7 +368,7 @@ void failsafe_rx_intr_uninstall_subdevice(struct sub_de= vice *sdev) struct rte_eth_dev *fsdev; struct rxq *fsrxq; =20 - fsdev =3D sdev->fs_dev; + fsdev =3D fs_dev(sdev); for (qid =3D 0; qid < ETH(sdev)->data->nb_rx_queues; qid++) { if (qid < fsdev->data->nb_rx_queues) { fsrxq =3D fsdev->data->rx_queues[qid]; diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe= /failsafe_private.h index 29dfd40..af0c9d1 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -117,7 +117,7 @@ struct sub_device { /* Others are retrieved through a file descriptor */ char *fd_str; /* fail-safe device backreference */ - struct rte_eth_dev *fs_dev; + uint16_t fs_port_id; /* shared between processes */ /* flag calling for recollection */ volatile unsigned int remove:1; /* flow isolation state */ @@ -324,16 +324,16 @@ extern int failsafe_mac_from_arg; */ #define FS_ATOMIC_RX(s, i) \ rte_atomic64_read( \ - &((struct rxq *)((s)->fs_dev->data->rx_queues[i]))->refcnt[(s)->sid] \ - ) + &((struct rxq *) \ + (fs_dev(s)->data->rx_queues[i]))->refcnt[(s)->sid]) /** * s: (struct sub_device *) * i: uint16_t qid */ #define FS_ATOMIC_TX(s, i) \ rte_atomic64_read( \ - &((struct txq *)((s)->fs_dev->data->tx_queues[i]))->refcnt[(s)->sid] \ - ) + &((struct txq *) \ + (fs_dev(s)->data->tx_queues[i]))->refcnt[(s)->sid]) =20 #ifdef RTE_EXEC_ENV_BSDAPP #define FS_THREADID_TYPE void* @@ -379,6 +379,11 @@ fs_find_next(struct rte_eth_dev *dev, return &subs[sid]; } =20 +static inline struct rte_eth_dev * +fs_dev(struct sub_device *sdev) { + return &rte_eth_devices[sdev->fs_port_id]; +} + /* * Lock hot-plug mutex. * is_alarm means that the caller is, for sure, the hot-plug alarm mechani= sm. --=20 2.7.4 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 1519FA05FE for ; Mon, 18 Mar 2019 17:06:03 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5C3454CC0; Mon, 18 Mar 2019 17:05:37 +0100 (CET) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50082.outbound.protection.outlook.com [40.107.5.82]) by dpdk.org (Postfix) with ESMTP id BE942378B for ; Mon, 18 Mar 2019 17:05:28 +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=0hmhNFW5FgewvwTKEv5zLy2s+uPR2WClPU1zgtPzNdM=; b=Wofg7t+TRxpSY1s1figrSNgEM08oJbhRSMCkkaxexSIHU2MeqkqA4/17OlAyEQa0zvGINMuUc+uwPvPXI+ZU9e+3qAXzUNI7FydObNwu+WptJyCZqwq3tLWzipWRQ/0DgoYuBpIRTNc8OjdFhsGZQp6uYRnX3OIpLB41WHvH9tM= Received: from AM6PR05MB5926.eurprd05.prod.outlook.com (20.179.2.27) by AM6PR05MB5798.eurprd05.prod.outlook.com (20.178.94.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1709.14; Mon, 18 Mar 2019 16:05:26 +0000 Received: from AM6PR05MB5926.eurprd05.prod.outlook.com ([fe80::ddb7:2093:62c0:59fb]) by AM6PR05MB5926.eurprd05.prod.outlook.com ([fe80::ddb7:2093:62c0:59fb%2]) with mapi id 15.20.1709.015; Mon, 18 Mar 2019 16:05:26 +0000 From: Raslan Darawsheh To: "gaetan.rivet@6wind.com" CC: "dev@dpdk.org" , Thomas Monjalon , Raslan Darawsheh , "stephen@networkplumber.org" Thread-Topic: [PATCH v3 2/4] net/failsafe: change back-reference from sub-device Thread-Index: AQHU3aRmMi7p3R57b0Sk36vulWuvOw== Date: Mon, 18 Mar 2019 16:05:26 +0000 Message-ID: <1552925103-2821-3-git-send-email-rasland@mellanox.com> References: <1551779507-10857-1-git-send-email-rasland@mellanox.com> <1552925103-2821-1-git-send-email-rasland@mellanox.com> In-Reply-To: <1552925103-2821-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: LNXP123CA0003.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:d2::15) 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: 818f0fbb-5f33-4625-a687-08d6abbb8882 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:AM6PR05MB5798; x-ms-traffictypediagnostic: AM6PR05MB5798: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-forefront-prvs: 098076C36C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(136003)(346002)(366004)(396003)(189003)(199004)(68736007)(6486002)(36756003)(316002)(8936002)(50226002)(5640700003)(53936002)(6916009)(6436002)(71200400001)(97736004)(71190400001)(6512007)(256004)(3846002)(14444005)(6116002)(86362001)(66066001)(2906002)(76176011)(52116002)(5660300002)(54906003)(2616005)(386003)(102836004)(81156014)(81166006)(478600001)(26005)(186003)(6506007)(8676002)(305945005)(14454004)(106356001)(4326008)(105586002)(2501003)(11346002)(446003)(2351001)(476003)(7736002)(99286004)(25786009)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR05MB5798; 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: pnKXLBTx8oNWYIH6KdhgfFI1mqFa3Wl5LXKs1we62M80EUyjWlA29jY3l8STWhVvVHyd9BRh5K1wZOxIG9D8cuqRMEys4DuQdGcADfb3cNPvUc9+RZiFVTHDu2aLx+KJP/l+0aY4UTIwDbRKFBSPgxdB0VHLGBsC5sj3DamnBXy0EEyBDe+cTrRiP/gtIJMR+ruHtHDy2Xa9S9my6QPdYRNtRJ1E/KXYj6tuf4jV4rgFhJp3kH9TCms1oJK+VJw0V129h7ASJ+11XZ+bLCeXiVeUMnEwhx2kFVuTLZNC5yhvFfallKdrn1eJqaPEJcCFZWkljSBfOHoh3gIySYn8fqTchwWUFYVRIL2MnysfIg1mBkWEJOdU3tbrYqiVyG0+MujX4+IkaSdn49BIb57e/wRTpvG387sWc9Fk+AvsESs= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 818f0fbb-5f33-4625-a687-08d6abbb8882 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2019 16:05:26.1004 (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: AM6PR05MB5798 Subject: [dpdk-dev] [PATCH v3 2/4] net/failsafe: change back-reference from sub-device 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190318160526.ico-0gTMA56dhhKDWNttk6R408ZHEJiUSncqwVp7t9k@z> In multiprocess context, the sub-device structure is shared between processes. The reference to the failsafe device was a per process pointer. It's changed to port id which is the same for all processes. Signed-off-by: Raslan Darawsheh Signed-off-by: Thomas Monjalon --- v2: changed macro to an inline function v3: changed prefix of inline function. =20 --- drivers/net/failsafe/failsafe_eal.c | 2 +- drivers/net/failsafe/failsafe_ether.c | 15 ++++++++------- drivers/net/failsafe/failsafe_intr.c | 10 +++++----- drivers/net/failsafe/failsafe_private.h | 15 ++++++++++----- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/drivers/net/failsafe/failsafe_eal.c b/drivers/net/failsafe/fai= lsafe_eal.c index 8a888b1..56d1669 100644 --- a/drivers/net/failsafe/failsafe_eal.c +++ b/drivers/net/failsafe/failsafe_eal.c @@ -114,7 +114,7 @@ fs_bus_init(struct rte_eth_dev *dev) } ETH(sdev) =3D &rte_eth_devices[pid]; SUB_ID(sdev) =3D i; - sdev->fs_dev =3D dev; + sdev->fs_port_id =3D dev->data->port_id; sdev->dev =3D ETH(sdev)->device; sdev->state =3D DEV_PROBED; } diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/f= ailsafe_ether.c index 1783165..7fa209a 100644 --- a/drivers/net/failsafe/failsafe_ether.c +++ b/drivers/net/failsafe/failsafe_ether.c @@ -298,7 +298,7 @@ fs_dev_remove(struct sub_device *sdev) break; } sdev->remove =3D 0; - failsafe_hotplug_alarm_install(sdev->fs_dev); + failsafe_hotplug_alarm_install(fs_dev(sdev)); } =20 static void @@ -318,8 +318,9 @@ fs_dev_stats_save(struct sub_device *sdev) WARN("Using latest snapshot taken before %"PRIu64" seconds.\n", (rte_rdtsc() - timestamp) / rte_get_tsc_hz()); } - failsafe_stats_increment(&PRIV(sdev->fs_dev)->stats_accumulator, - err ? &sdev->stats_snapshot.stats : &stats); + failsafe_stats_increment + (&PRIV(fs_dev(sdev))->stats_accumulator, + err ? &sdev->stats_snapshot.stats : &stats); memset(&sdev->stats_snapshot, 0, sizeof(sdev->stats_snapshot)); } =20 @@ -566,17 +567,17 @@ failsafe_eth_rmv_event_callback(uint16_t port_id __rt= e_unused, { struct sub_device *sdev =3D cb_arg; =20 - fs_lock(sdev->fs_dev, 0); + fs_lock(fs_dev(sdev), 0); /* Switch as soon as possible tx_dev. */ - fs_switch_dev(sdev->fs_dev, sdev); + fs_switch_dev(fs_dev(sdev), sdev); /* Use safe bursts in any case. */ - failsafe_set_burst_fn(sdev->fs_dev, 1); + failsafe_set_burst_fn(fs_dev(sdev), 1); /* * Async removal, the sub-PMD will try to unregister * the callback at the source of the current thread context. */ sdev->remove =3D 1; - fs_unlock(sdev->fs_dev, 0); + fs_unlock(fs_dev(sdev), 0); return 0; } =20 diff --git a/drivers/net/failsafe/failsafe_intr.c b/drivers/net/failsafe/fa= ilsafe_intr.c index 09aa3c6..0f34c5b 100644 --- a/drivers/net/failsafe/failsafe_intr.c +++ b/drivers/net/failsafe/failsafe_intr.c @@ -274,14 +274,14 @@ failsafe_eth_rx_intr_ctl_subdevice(struct sub_device = *sdev, int op) int rc; int ret =3D 0; =20 + fsdev =3D fs_dev(sdev); if (sdev =3D=3D NULL || (ETH(sdev) =3D=3D NULL) || - sdev->fs_dev =3D=3D NULL || (PRIV(sdev->fs_dev) =3D=3D NULL)) { + fsdev =3D=3D NULL || (PRIV(fsdev) =3D=3D NULL)) { ERROR("Called with invalid arguments"); return -EINVAL; } dev =3D ETH(sdev); - fsdev =3D sdev->fs_dev; - epfd =3D PRIV(sdev->fs_dev)->rxp.efd; + epfd =3D PRIV(fsdev)->rxp.efd; pid =3D PORT_ID(sdev); =20 if (epfd <=3D 0) { @@ -330,7 +330,7 @@ int failsafe_rx_intr_install_subdevice(struct sub_devic= e *sdev) const struct rte_intr_conf *const intr_conf =3D Ð(sdev)->data->dev_conf.intr_conf; =20 - fsdev =3D sdev->fs_dev; + fsdev =3D fs_dev(sdev); rxq =3D (struct rxq **)fsdev->data->rx_queues; if (intr_conf->rxq =3D=3D 0) return 0; @@ -368,7 +368,7 @@ void failsafe_rx_intr_uninstall_subdevice(struct sub_de= vice *sdev) struct rte_eth_dev *fsdev; struct rxq *fsrxq; =20 - fsdev =3D sdev->fs_dev; + fsdev =3D fs_dev(sdev); for (qid =3D 0; qid < ETH(sdev)->data->nb_rx_queues; qid++) { if (qid < fsdev->data->nb_rx_queues) { fsrxq =3D fsdev->data->rx_queues[qid]; diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe= /failsafe_private.h index 29dfd40..af0c9d1 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -117,7 +117,7 @@ struct sub_device { /* Others are retrieved through a file descriptor */ char *fd_str; /* fail-safe device backreference */ - struct rte_eth_dev *fs_dev; + uint16_t fs_port_id; /* shared between processes */ /* flag calling for recollection */ volatile unsigned int remove:1; /* flow isolation state */ @@ -324,16 +324,16 @@ extern int failsafe_mac_from_arg; */ #define FS_ATOMIC_RX(s, i) \ rte_atomic64_read( \ - &((struct rxq *)((s)->fs_dev->data->rx_queues[i]))->refcnt[(s)->sid] \ - ) + &((struct rxq *) \ + (fs_dev(s)->data->rx_queues[i]))->refcnt[(s)->sid]) /** * s: (struct sub_device *) * i: uint16_t qid */ #define FS_ATOMIC_TX(s, i) \ rte_atomic64_read( \ - &((struct txq *)((s)->fs_dev->data->tx_queues[i]))->refcnt[(s)->sid] \ - ) + &((struct txq *) \ + (fs_dev(s)->data->tx_queues[i]))->refcnt[(s)->sid]) =20 #ifdef RTE_EXEC_ENV_BSDAPP #define FS_THREADID_TYPE void* @@ -379,6 +379,11 @@ fs_find_next(struct rte_eth_dev *dev, return &subs[sid]; } =20 +static inline struct rte_eth_dev * +fs_dev(struct sub_device *sdev) { + return &rte_eth_devices[sdev->fs_port_id]; +} + /* * Lock hot-plug mutex. * is_alarm means that the caller is, for sure, the hot-plug alarm mechani= sm. --=20 2.7.4