From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140070.outbound.protection.outlook.com [40.107.14.70]) by dpdk.org (Postfix) with ESMTP id 5B6B027D for ; Tue, 5 Mar 2019 10:52:06 +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=AO3HqJzPmEsQ/u1y53cJvqXuv/OHLW66VnBNEaTReJqjh6x+s9uCJRh0lKa9lYy7kliDdjtMq5byTVUZHsVOe/RquMB2/2GxDGzUUD9Y4Q+a1FKpiHX+QrzTSc4LgrznOXwPLrbA0mRLHu6HImDOHfzCCPbKcocLM5eNSEPWvH8= Received: from AM6PR05MB5926.eurprd05.prod.outlook.com (20.179.2.27) by AM6PR05MB4487.eurprd05.prod.outlook.com (52.135.162.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.18; Tue, 5 Mar 2019 09:52:04 +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.1665.020; Tue, 5 Mar 2019 09:52:04 +0000 From: Raslan Darawsheh To: "gaetan.rivet@6wind.com" CC: "dev@dpdk.org" , Thomas Monjalon , Raslan Darawsheh , "stephen@networkplumber.org" Thread-Topic: [PATCH v2 1/4] net/failsafe: replace local device with shared data Thread-Index: AQHU0zkWpQQ0tJBEq0y+SFUxHGBAuw== Date: Tue, 5 Mar 2019 09:52:04 +0000 Message-ID: <1551779507-10857-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: LO2P265CA0426.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a0::30) 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: 921d3de5-e6fb-4f2b-cb08-08d6a1503889 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:AM6PR05MB4487; x-ms-traffictypediagnostic: AM6PR05MB4487: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; AM6PR05MB4487; 23:aZ90nKzJxCiURdr1tGnvs/qaWT5gLnOBiI36RLo?= =?iso-8859-1?Q?+ZgbjlPWqUZpWdxAqGJ879Tr015yyE4+VbZk4f4MDneGKnuPWX6yjLThi7?= =?iso-8859-1?Q?UR/akEWqY8c9u7f8h5UmRUNMu/agbvgUWs57UTnzpeQHKyRBf2spYDJM4l?= =?iso-8859-1?Q?y2MO3SRyNA45bH/NYI+ACPuzfufbaoWxS7OM+iDlbfcEpvnkgxQVDSllYn?= =?iso-8859-1?Q?5LrGKpim4azMmOeucqHiJPgQtdPSVQtYyzfyBFHwcoERrTum97ZElDChFp?= =?iso-8859-1?Q?i/sUxvLdN8hMtHY2NVAr/DK2DecnToiuNrtburBktwmoTIOpSdo/ckytAC?= =?iso-8859-1?Q?xXgG0JD2Aqe6P6LG6NupXUxXOWth/IkmuopOzt9UzQ8WJFS7qfCyQ6EC0U?= =?iso-8859-1?Q?FJ+sShlbDa8AKjpxhTzCgQXnhaULRb6GQ47tc5sBf/lxVDX5DR8/OKRaD4?= =?iso-8859-1?Q?oT1NG4nFp42t6vsouB0/VhBX8TaR1yufAz1XvtjnG96VEqmVzNWqIlnYw8?= =?iso-8859-1?Q?1uK1mXj0WKL3sbih2ibjU8AbTZm8UW58xyoSpyI2/y3pIE0k0JPlY/2fFc?= =?iso-8859-1?Q?0eA8PmoKQeIfaBpvXmKxuJOhANx6li6K7QDivcy56k3tabsrKJPGqNOAIq?= =?iso-8859-1?Q?MUd1/6B/hGMyc5nij+3Gf95IoerFfDiFir00d3xbqoP86xRr8cAV/m/rQR?= =?iso-8859-1?Q?gBNaCJf1fwhMM0uzBp1BTWJsnLl13/vmugdQwiTtCsjgyYNJgqZqY6h5Lg?= =?iso-8859-1?Q?0sFhpZQQgPrmgxH0GGKMSYtWSnl/MHzG4/8hkVfjBqB429JoSdNid5hj02?= =?iso-8859-1?Q?9s/yIgDWWxaAjlOaOQdXTMt2aX5VIqDqHipXZOVwdKT0i8fkrCbuGMB153?= =?iso-8859-1?Q?aReiyna2RMXvxbuKIJCAUyYc4FoEBERQNYEH4PwJ8+k168dmuXs+uYz0kG?= =?iso-8859-1?Q?TzIvTUoZ1ZqhgV85wZWeEw5bC/oi4aaVG+mCDc6qgARlvjor//loWxTFRF?= =?iso-8859-1?Q?+HAVBuUqYvZDR2iQ3UcYIONQEhbz2u87V8nsHRyePu+jWZruu6VaASvEbi?= =?iso-8859-1?Q?2how428ZPU2GEGdDK2Kouu0pohuWukS16m7dGYB8gKyywoUvrioFOnhzOM?= =?iso-8859-1?Q?uehFR3Pko3dQCdMhfSn8nRzgJfOXhmXKJQZRqOchWtzvLCIVwDasX+aMIP?= =?iso-8859-1?Q?TOwb+KlD1MFEjl7Y+WGTR4uKZXnupwxTWezHMThkthHz8GiA9OsUwBx7Wo?= =?iso-8859-1?Q?55r+YiyX9quBb2gY4?= x-microsoft-antispam-prvs: x-forefront-prvs: 0967749BC1 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(396003)(376002)(366004)(136003)(346002)(189003)(199004)(25786009)(486006)(8936002)(6916009)(3846002)(53936002)(6512007)(52116002)(102836004)(2351001)(2906002)(5660300002)(2501003)(66066001)(97736004)(478600001)(99286004)(305945005)(106356001)(186003)(6486002)(386003)(26005)(14454004)(50226002)(316002)(4326008)(6506007)(68736007)(71190400001)(54906003)(71200400001)(105586002)(476003)(5640700003)(7736002)(256004)(36756003)(14444005)(86362001)(6116002)(8676002)(6436002)(2616005)(81166006)(81156014); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR05MB4487; 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: KIN+CxrtnM2Fp9ZQInlylveEbG98NENQjkdhTkeH7b42fmyL57ubO9IeiXFnw4dKsxRs5puhpacUx807vVDj8n4jZoxJSJoQ9bEu4Qo59Bik3vqUo6Aa3vtFnHb1jhTWrvx0N7fQdtUtLMD0OKj1PRNbc8sR++WMq02OVg/0eyqw1Hax62dkV08KX3m6NVekZ6AWDnnSvfCAmLbhuwnOgprV5nugRSoYC44qHwPUGPmpK1MFFcXz8Cx1MZnhfGM20bKcZHfGeBHam6G1g5ff2DxwUdZP/tCglejCPA7UIy4UI6+ob+Yxq1tUHLXhQouyUmQf8KAouaf73PMpV2b4kjmy0XGGe0nw0FPbKwBcUgzZrnkOO8RC0zsWan9AMExU+1Dj6hRY/idv9qPclYBNj1FY3lPuLLjc6dbsZtP7Wls= 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: 921d3de5-e6fb-4f2b-cb08-08d6a1503889 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Mar 2019 09:52:04.1486 (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: AM6PR05MB4487 Subject: [dpdk-dev] [PATCH v2 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: Tue, 05 Mar 2019 09:52:06 -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 | 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