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 48FA7A05FE for ; Mon, 18 Mar 2019 17:05:29 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E19322C54; Mon, 18 Mar 2019 17:05:27 +0100 (CET) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80075.outbound.protection.outlook.com [40.107.8.75]) by dpdk.org (Postfix) with ESMTP id A75732BAF for ; Mon, 18 Mar 2019 17:05:26 +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=TnzPXLe7FsBQ7jlGaz8G7XP8aOC/CHXono1Mf9dKV2Y=; b=gIrQtty1eQCCwNB3q8vn6oV6gpzqLUzxovDkpIjmYlPNocpDCIL9TSPr9vGK9IK1BrH83UzRxxK+29jLzV8BT4065hsFRw6pXdesf1Se+qwkVPAEJ5Rk01KFdQ624MokhLg8uGpr8J1TABG+/ECX5UjijMWjvD9/IPY4+gznjkg= 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:25 +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:25 +0000 From: Raslan Darawsheh To: "gaetan.rivet@6wind.com" CC: "dev@dpdk.org" , Thomas Monjalon , Raslan Darawsheh , "stephen@networkplumber.org" Thread-Topic: [PATCH v3 1/4] net/failsafe: replace local device with shared data Thread-Index: AQHU3aRlHyMftvdOSU2xKSPHNW7hQw== Date: Mon, 18 Mar 2019 16:05:25 +0000 Message-ID: <1552925103-2821-2-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: d936521c-9fe5-4149-f80b-08d6abbb87e7 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: FiH0myvQSokLR3DqPx3LICfi4Kp1ryX4lMVyJl0blvVxlfxvqj7ikB+WCTvYm5VIxmLu+/zZ9bX5XpPn/23PEKYVCOp2cwyWWwP6ItohGcg/ULQwgn2MCZYOSdbEl4WI1yZn6zJdVr2zoilh2VoEjWQX5HP0mUm9LmH9tUMM3ozd+TuMP8Y2S5gOIc7PE5cK1zg57zcE8/+9fbOLNa/kY5TYxvAhrP6ejjR5UtbApzgy2A6zzZpeGNCOsA0vdnjrjMjpbDi+MVw9E+MApTBDeSGVckP9zd8m7gvsBQJYOcJ08UO55wsIj+CboQYfQgsPfCuXhVxHlFFgPYwtdL7+P6WACeq+SwHsSSEI3ManQFl7PpJZp8mxjeQA4UQU2dS6LJKzF0kKQvvC936xx8lE/F4+yNK5i+htu8GBMHu9Sds= 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: d936521c-9fe5-4149-f80b-08d6abbb87e7 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2019 16:05:25.0717 (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 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190318160525.Pka_074imsXm2arEB81vUcuNnn-xKYrEq79-7CpG04c@z> 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 | 6 +++++- drivers/net/failsafe/failsafe_rxtx.c | 4 ++-- 5 files changed, 15 insertions(+), 11 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..29dfd40 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -128,8 +128,12 @@ 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 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