From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80041.outbound.protection.outlook.com [40.107.8.41]) by dpdk.org (Postfix) with ESMTP id 843CD44BE for ; Thu, 28 Feb 2019 16:49:27 +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=38LIni2rl2oReIYD/hOCErzlPkOylAk7R5uHU6fCzZg=; b=na6zPQv7SvreIILwovDv7ZtBBcHR5dTmVzcIWTy4aH2jYygNcVjpj6mLTNTurhCmnguHtigb4peBvzbRRJdibO/AZ4nnFQXPHizL/Pg0goxyj032lwG2KR7WoCGM00jeInL7HFB4kstHQU+dsIeWmFDVhqIQ1pJ26Qga+iok73A= 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:26 +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:26 +0000 From: Raslan Darawsheh To: "gaetan.rivet@6wind.com" CC: "dev@dpdk.org" , Thomas Monjalon , Raslan Darawsheh Thread-Topic: [PATCH 1/4] net/failsafe: replace local device with shared data Thread-Index: AQHUz30uklCFRK5rKUi+XcUCQDmtLg== Date: Thu, 28 Feb 2019 15:49:26 +0000 Message-ID: <1551368952-1871-2-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: fde37073-e5fe-4f02-670c-08d69d9450f2 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:lb6inJzpWyytmnCCSHrnprj+ju0pNgyYFVhd/Cv?= =?iso-8859-1?Q?nvJ9T/yNa2fXWWfr7RSe8uLn4htz+Fdxlq2ubcvMOfPmIoqQOmjSDuMr3R?= =?iso-8859-1?Q?zXuQwxwRr5HKxVevFFWpa6LxQhnXcBlDaQJoR3Z/Z+6LyJ/ShGCM9FSnkR?= =?iso-8859-1?Q?cxT4j4niGHdO4S3SN1zhlrjBYDlL+phMK/U2bWbh9olI6T000xP6TD3bvj?= =?iso-8859-1?Q?TAiZieJKbtFbXisYGu1fzF4aV7h1Xp3c3rwcesjHROP0AncTdxJf3KcspQ?= =?iso-8859-1?Q?ISpWQE6hTl0oqGJjRmLUGLnqxy0GYQ/bJs4Zv1+ZrQCfMiR/LcfPkueWQa?= =?iso-8859-1?Q?byPcUUOMMSHCs8WA4x9YlO78DK87yVRE0KWEJhZnq2rHIGHsidaq4tNJ3A?=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XgNlkfICj0ezd8O1u3Q55oeW+IK+LgN4T?= =?iso-8859-1?Q?OXpegFFz4A5AKsZQa8mpBfEJb22sO1A0AtORgBSSzWKBw=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: 07Hm1OTLuitPD3eEOhZ9j+QdUPIzSJCPfHw75ZIvQlLw5ZQL93Dcf0br88xZnfIEvE2H9MbQmxestVj/RJWxgeOGsYtycQqytmFryYFRQyyHZ265JjcOoqUFX350j7bZzcdedrcH8K3Xq6EEA5fLWtrBj52V6Z3sSOmHlPAGv8fZSLugVpTNyQC1I1Ee41EwIuvKXiMroMKf8O3k0gFhtEMdUVRodA6y4wmTNRpb8MAqxdH9Q2yA4bkZXmxYjNQQcNod5jFBl7grK46Bmn5EfdQpj+guorsCjvTYrGvq5ElVnKieiW6GokzIIog8nW9T5hNv5RuwOXbw5imVgip1UkiaGcNzb/aMmQsECCv+efWzVbulpdA8oPS/LOLFM/kbLfqV6JWe5t4FApB7hPSdDRpfxRfMunsHfykOMUHAkDM= 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: fde37073-e5fe-4f02-670c-08d69d9450f2 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2019 15:49:25.3534 (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 1/4] net/failsafe: replace local 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:27 -0000 In multiprocess context, the private structure is shared between processes. The back reference from private to generic data was using a pointer to a per process eth_dev. It's now changed to a reference of the shared data. Signed-off-by: Raslan Darawsheh Signed-off-by: Thomas Monjalon --- drivers/net/failsafe/failsafe.c | 2 +- drivers/net/failsafe/failsafe_intr.c | 10 +++++----- drivers/net/failsafe/failsafe_ops.c | 4 ++-- drivers/net/failsafe/failsafe_private.h | 8 ++++++-- drivers/net/failsafe/failsafe_rxtx.c | 4 ++-- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsaf= e.c index 06e859e..68926ca 100644 --- a/drivers/net/failsafe/failsafe.c +++ b/drivers/net/failsafe/failsafe.c @@ -181,7 +181,7 @@ fs_eth_dev_create(struct rte_vdev_device *vdev) return -1; } priv =3D PRIV(dev); - priv->dev =3D dev; + priv->data =3D dev->data; dev->dev_ops =3D &failsafe_ops; dev->data->mac_addrs =3D &PRIV(dev)->mac_addrs[0]; dev->data->dev_link =3D eth_link; diff --git a/drivers/net/failsafe/failsafe_intr.c b/drivers/net/failsafe/fa= ilsafe_intr.c index 1c2cb71..09aa3c6 100644 --- a/drivers/net/failsafe/failsafe_intr.c +++ b/drivers/net/failsafe/failsafe_intr.c @@ -133,8 +133,8 @@ fs_rx_event_proxy_service_install(struct fs_priv *priv) /* prepare service info */ memset(&service, 0, sizeof(struct rte_service_spec)); snprintf(service.name, sizeof(service.name), "%s_Rx_service", - priv->dev->data->name); - service.socket_id =3D priv->dev->data->numa_node; + priv->data->name); + service.socket_id =3D priv->data->numa_node; service.callback =3D fs_rx_event_proxy_routine; service.callback_userdata =3D priv; =20 @@ -437,7 +437,7 @@ fs_rx_intr_vec_install(struct fs_priv *priv) unsigned int count; struct rte_intr_handle *intr_handle; =20 - rxqs_n =3D priv->dev->data->nb_rx_queues; + rxqs_n =3D priv->data->nb_rx_queues; n =3D RTE_MIN(rxqs_n, (uint32_t)RTE_MAX_RXTX_INTR_VEC_ID); count =3D 0; intr_handle =3D &priv->intr_handle; @@ -452,7 +452,7 @@ fs_rx_intr_vec_install(struct fs_priv *priv) return -rte_errno; } for (i =3D 0; i < n; i++) { - struct rxq *rxq =3D priv->dev->data->rx_queues[i]; + struct rxq *rxq =3D priv->data->rx_queues[i]; =20 /* Skip queues that cannot request interrupts. */ if (rxq =3D=3D NULL || rxq->event_fd < 0) { @@ -521,7 +521,7 @@ failsafe_rx_intr_install(struct rte_eth_dev *dev) { struct fs_priv *priv =3D PRIV(dev); const struct rte_intr_conf *const intr_conf =3D - &priv->dev->data->dev_conf.intr_conf; + &priv->data->dev_conf.intr_conf; =20 if (intr_conf->rxq =3D=3D 0 || dev->intr_handle !=3D NULL) return 0; diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/fai= lsafe_ops.c index e3add40..65957a2 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -452,7 +452,7 @@ fs_rx_queue_release(void *queue) if (queue =3D=3D NULL) return; rxq =3D queue; - dev =3D rxq->priv->dev; + dev =3D &rte_eth_devices[rxq->priv->data->port_id]; fs_lock(dev, 0); if (rxq->event_fd > 0) close(rxq->event_fd); @@ -636,7 +636,7 @@ fs_tx_queue_release(void *queue) if (queue =3D=3D NULL) return; txq =3D queue; - dev =3D txq->priv->dev; + dev =3D &rte_eth_devices[txq->priv->data->port_id]; fs_lock(dev, 0); FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { if (ETH(sdev)->data->tx_queues !=3D NULL && diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe= /failsafe_private.h index 0dfea65..91b7167 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -128,14 +128,18 @@ struct sub_device { unsigned int lsc_callback:1; }; =20 +/* + * This is referenced by eth_dev->data->dev_private + * This is shared between processes. + */ struct fs_priv { - struct rte_eth_dev *dev; + struct rte_eth_dev_data *data; /* backreference to shared data. */ /* * Set of sub_devices. * 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 */ diff --git a/drivers/net/failsafe/failsafe_rxtx.c b/drivers/net/failsafe/fa= ilsafe_rxtx.c index 034f47b..231c832 100644 --- a/drivers/net/failsafe/failsafe_rxtx.c +++ b/drivers/net/failsafe/failsafe_rxtx.c @@ -126,7 +126,7 @@ failsafe_tx_burst(void *queue, uint16_t nb_tx; =20 txq =3D queue; - sdev =3D TX_SUBDEV(txq->priv->dev); + sdev =3D TX_SUBDEV(&rte_eth_devices[txq->priv->data->port_id]); if (unlikely(fs_tx_unsafe(sdev))) return 0; sub_txq =3D ETH(sdev)->data->tx_queues[txq->qid]; @@ -147,7 +147,7 @@ failsafe_tx_burst_fast(void *queue, uint16_t nb_tx; =20 txq =3D queue; - sdev =3D TX_SUBDEV(txq->priv->dev); + sdev =3D TX_SUBDEV(&rte_eth_devices[txq->priv->data->port_id]); RTE_ASSERT(!fs_tx_unsafe(sdev)); sub_txq =3D ETH(sdev)->data->tx_queues[txq->qid]; FS_ATOMIC_P(txq->refcnt[sdev->sid]); --=20 2.7.4