From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80052.outbound.protection.outlook.com [40.107.8.52]) by dpdk.org (Postfix) with ESMTP id 6C13844BE for ; Thu, 28 Feb 2019 16:49: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=HRy4Kuk4U/CZA+3ZjFi3b+Qpi9PpelS9e6mfPAAD1kQ=; b=FcXxAkItFIpaiNrAzj3+yEzW5z0enUQ4mfvZ8t8rabtMu4Pf+YIZixp3S5SOV62ywm47S+acN8pv6bM2KE985ggiRfydjQDXwjCiRB5UzCy571Ky/AgzeZ/U/Wtze8otDMx2stlGyZrNRe7aQcIQ5n0kkQ1UP5uqsHcNTCZSG5Y= 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 2/4] net/failsafe: change back-reference from sub-device Thread-Index: AQHUz30vknUAmBEjI0WYbuxibRzVew== Date: Thu, 28 Feb 2019 15:49:26 +0000 Message-ID: <1551368952-1871-3-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: 20dbeab9-7403-48b8-6e38-08d69d945173 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:na4Vt6qm+xkhUo5xk5IaBaaL9xNKtKhQbBdajIM?= =?iso-8859-1?Q?8AN7QP8o4Bz5YUp+XMClGAxlAA55g5dO5grEoiu5ChfSN1Fw8b1TU2I7eN?= =?iso-8859-1?Q?hZN+G1J2zEWkYqdfBFtU0kdojlZn7qjHyLZCSQfZ4nw7Wnp2paqkP8q0KB?= =?iso-8859-1?Q?0i9m7q3rLUXcnfYHhWQpeadnEExVUi3QGJCGiAua3ZrmXA6sPDa3lpD3Wt?= =?iso-8859-1?Q?GRm1luEogPLEJn5i9uEQghaF/QhJfLiZCmv9u3oKCr+d7BhoPzmGHGZuOU?= =?iso-8859-1?Q?rgkNN/FHS0ZwSVocqZAxVXN81PSOX9fj11dXndkNxfQqbjtHJzQ1AD3XGj?= =?iso-8859-1?Q?CJ3w7cnZh88+lNPWR3cJil8DTQx7ngMxdOgRFRW4+N7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RR8JoO4PtQyVKVCHkh6lbwDSkWrpLgES3QhGOmw03k24e8hBn7fT5ux2i?= =?iso-8859-1?Q?A2wv+hNIHvMu3k9sI2lUDDUX91raNLliWghDu8Tt/13mw=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: e64Rk+ePTtl1GA78MtMHY2BaQTLtANUKOX70EMWpZupzFQ+Mw8dPIm6xAnUBV1f9Yp0SLgduUyWR8nv+mggI5piOpN50BOLiAGxwZ7EdXcErYLGXzo5GBBsh8AZ64dcFnJUO3NOEL0N47xgnu3gAiOp1DagIIoM4Jh0lN6cWsj6JyPB2H+wFEQGhCy2BZG4rX63D7vlFTiU9x2SBRVnHxFMoSc7NVIr9eRtH1j1r9QlH01mDUJwFoJjckFD4Bmta0isZvAKMy4PFjgQXfH8yQD9UmgTgrhRWb2zBMrH1hzfDdaskjMpk2/psEw+mX3mB/zt0gkdXUgDKrNNWLHn/zkFyijI6exEdo9VRaQOh4WYHAVpOpupD+KIcqE9+BwbAEWYfxnMUgwDUXFonpDN75vaY0uZd1eMzA73kTTDr+x0= 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: 20dbeab9-7403-48b8-6e38-08d69d945173 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2019 15:49:26.2220 (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 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: Thu, 28 Feb 2019 15:49:28 -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 --- 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 | 11 ++++++++--- 4 files changed, 22 insertions(+), 16 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..8d958e0 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(FSDEV_FROM_SUBDEV(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(FSDEV_FROM_SUBDEV(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(FSDEV_FROM_SUBDEV(sdev), 0); /* Switch as soon as possible tx_dev. */ - fs_switch_dev(sdev->fs_dev, sdev); + fs_switch_dev(FSDEV_FROM_SUBDEV(sdev), sdev); /* Use safe bursts in any case. */ - failsafe_set_burst_fn(sdev->fs_dev, 1); + failsafe_set_burst_fn(FSDEV_FROM_SUBDEV(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(FSDEV_FROM_SUBDEV(sdev), 0); return 0; } =20 diff --git a/drivers/net/failsafe/failsafe_intr.c b/drivers/net/failsafe/fa= ilsafe_intr.c index 09aa3c6..6fe5816 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 FSDEV_FROM_SUBDEV(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 FSDEV_FROM_SUBDEV(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 FSDEV_FROM_SUBDEV(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 91b7167..9b53a19 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 */ @@ -251,6 +251,9 @@ extern int failsafe_mac_from_arg; /* dev: (struct rte_eth_dev *) fail-safe device */ #define PRIV(dev) \ ((struct fs_priv *)(dev)->data->dev_private) +/* sdev: (struct sub_device *) */ +#define FSDEV_FROM_SUBDEV(sdev) \ + (&rte_eth_devices[sdev->fs_port_id]) =20 /* sdev: (struct sub_device *) */ #define ETH(sdev) \ @@ -324,7 +327,8 @@ 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 *) \ + (FSDEV_FROM_SUBDEV(s)->data->rx_queues[i]))->refcnt[(s)->sid] \ ) /** * s: (struct sub_device *) @@ -332,7 +336,8 @@ extern int failsafe_mac_from_arg; */ #define FS_ATOMIC_TX(s, i) \ rte_atomic64_read( \ - &((struct txq *)((s)->fs_dev->data->tx_queues[i]))->refcnt[(s)->sid] \ + &((struct txq *) \ + (FSDEV_FROM_SUBDEV(s)->data->tx_queues[i]))->refcnt[(s)->sid] \ ) =20 #ifdef RTE_EXEC_ENV_BSDAPP --=20 2.7.4