From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80054.outbound.protection.outlook.com [40.107.8.54]) by dpdk.org (Postfix) with ESMTP id 5DCAE2C39 for ; Thu, 7 Mar 2019 10:01:14 +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=TgsZ1vtvsdaHXEs3eHOOit7TK6HpMH004/rYEeAVr2A=; b=IkLlDljoxXwhnY0GTi8kGzfcID8fJ8sJQamlYsn6dkUPyJAHuSbqQSSNbfkVD1QeCj3/ouFq9sdoHz6+zOa+ZSveZ3ZBQJKdKHxdK6nAeoaHX6mO9rNJYVy3odarHk+/3sGXgETCZfTvSIebhpMiubYLDiOTk0Dhv8dI7qbkWrQ= Received: from AM6PR05MB5926.eurprd05.prod.outlook.com (20.179.2.27) by AM6PR05MB5571.eurprd05.prod.outlook.com (20.177.119.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.16; Thu, 7 Mar 2019 09:01:11 +0000 Received: from AM6PR05MB5926.eurprd05.prod.outlook.com ([fe80::a0b3:8140:c1f1:dd89]) by AM6PR05MB5926.eurprd05.prod.outlook.com ([fe80::a0b3:8140:c1f1:dd89%3]) with mapi id 15.20.1686.018; Thu, 7 Mar 2019 09:01:11 +0000 From: Raslan Darawsheh To: =?iso-8859-1?Q?Ga=EBtan_Rivet?= CC: "dev@dpdk.org" , Thomas Monjalon , "stephen@networkplumber.org" Thread-Topic: [PATCH v2 2/4] net/failsafe: change back-reference from sub-device Thread-Index: AQHU0zkWSunmH/Ws/UiUZsH01gVz46X9QDAAgAKhZzA= Date: Thu, 7 Mar 2019 09:01:11 +0000 Message-ID: References: <1551779507-10857-1-git-send-email-rasland@mellanox.com> <1551779507-10857-2-git-send-email-rasland@mellanox.com> <20190305164854.2e5lb6o3j23vkpl3@bidouze.vm.6wind.com> In-Reply-To: <20190305164854.2e5lb6o3j23vkpl3@bidouze.vm.6wind.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=rasland@mellanox.com; x-originating-ip: [82.213.2.186] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: dc54a73e-6e88-4f3a-37c7-08d6a2db723f 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:AM6PR05MB5571; x-ms-traffictypediagnostic: AM6PR05MB5571: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; AM6PR05MB5571; 23:3M7sq4oJVb35tDSHNY3a1E9qmVzmcKmKHpLXsJ4?= =?iso-8859-1?Q?FImVNM7lKgr1pjsfJ1ZXEpEsfklBgC43E51F8WtnlYuo+VnfnmWR7ScOIt?= =?iso-8859-1?Q?JLPQcNtsQ7YfPfUExjXs0dhSJh099CRLGJTTxBqC+tTCAkeETh8cgoVtH/?= =?iso-8859-1?Q?eKC4giGKM1qQRSM6UhSFtv0S5Doh+/7YHQ62MeHZv6D0IBiiU0BBi1xXna?= =?iso-8859-1?Q?1K5W1bEF7QA7QgG1McbFrRB7whJSEpTde3xnTuu922sP8tTuTgiidCipAd?= =?iso-8859-1?Q?7ThEH18kurbIckgpPWRvLfkF3/HT1AdlQ6njGXzU8hwTmi3zYp2Eo6dAfi?= =?iso-8859-1?Q?iIeX/DfONLcvAN4Xd+EqQJLjQ1ttn8Y3DuwRXu3jwosB3C3ZSOYW5kZ5nq?= =?iso-8859-1?Q?3wfksP9GI/QDdWf6QyIAku/DziuZY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Nttxj7H0t2jMtuJ6/LjU7gM/YOefgovTGIUNKLMSj6MiQ=3D=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 096943F07A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(396003)(136003)(366004)(376002)(346002)(13464003)(199004)(189003)(106356001)(52536013)(5660300002)(7736002)(6246003)(99286004)(26005)(6916009)(33656002)(6436002)(229853002)(9686003)(81156014)(3846002)(6116002)(81166006)(97736004)(8676002)(55016002)(66066001)(256004)(14444005)(76176011)(68736007)(53546011)(53936002)(478600001)(486006)(4326008)(446003)(6506007)(54906003)(11346002)(476003)(25786009)(102836004)(71190400001)(71200400001)(8936002)(74316002)(7696005)(2906002)(186003)(305945005)(14454004)(86362001)(66574012)(105586002)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR05MB5571; H:AM6PR05MB5926.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX: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: I0a0WQ21duihBQdPwrb6agzwl2/8gZiDz/HD1cDfWsO9vgwxCDAcG9Fk/pWlkZIaIU2NePudPH2rQhFZBjs0MktO1xGEpOkzhP1HjQNlNZoSKLfArx1moTnslSe82z/bsYAgugmy2CB7Qvybh8eu6gv/Kg48pttB1vP3QunuN4eRvkXZjEdlCXCUeuc/iQ6fJnixy4cJGWmZz8TYBXXEWhgPRFD2R9gT/WY2CeQ/NGVqqyhq1p7vU8evf+AuCzbiEfen1t24VH1XkP7Lo0Ig/bhjt10iP7CSs29xGUqFsoMwkZPTPuioR09nPQUnFve9bWqJbMETngq+lv17TG/uAmMUJokWR+jKzQXZQwoPQzuX29bjUumKulpaklpu93eiT8qADfbT4GbwBM3TWmngjmVRiFk2BOeRgEzKObnob7Y= 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: dc54a73e-6e88-4f3a-37c7-08d6a2db723f X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Mar 2019 09:01:11.6816 (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: AM6PR05MB5571 Subject: Re: [dpdk-dev] [PATCH v2 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, 07 Mar 2019 09:01:14 -0000 Hi, > -----Original Message----- > From: Ga=EBtan Rivet > Sent: Tuesday, March 5, 2019 6:49 PM > To: Raslan Darawsheh > Cc: dev@dpdk.org; Thomas Monjalon ; > stephen@networkplumber.org > Subject: Re: [PATCH v2 2/4] net/failsafe: change back-reference from sub- > device >=20 > Beside the squash referenced in p1, >=20 > On Tue, Mar 05, 2019 at 09:52:05AM +0000, Raslan Darawsheh wrote: > > 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 > > --- > > 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 | 13 ++++++++++--- > > 4 files changed, 24 insertions(+), 16 deletions(-) > > > > diff --git a/drivers/net/failsafe/failsafe_eal.c > > b/drivers/net/failsafe/failsafe_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/failsafe_ether.c > > index 1783165..d5b1488 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)); > > } > > > > 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)); > } > > > > @@ -566,17 +567,17 @@ failsafe_eth_rmv_event_callback(uint16_t > port_id > > __rte_unused, { > > struct sub_device *sdev =3D cb_arg; > > > > - 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; > > } > > > > diff --git a/drivers/net/failsafe/failsafe_intr.c > > b/drivers/net/failsafe/failsafe_intr.c > > index 09aa3c6..d372d09 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; > > > > + 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); > > > > if (epfd <=3D 0) { > > @@ -330,7 +330,7 @@ int failsafe_rx_intr_install_subdevice(struct > sub_device *sdev) > > const struct rte_intr_conf *const intr_conf =3D > > Ð(sdev)->data->dev_conf.intr_conf; > > > > - 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_device *sdev) > > struct rte_eth_dev *fsdev; > > struct rxq *fsrxq; > > > > - 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 29dfd40..84e847f 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,7 +324,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 +333,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] \ > > ) > > > > #ifdef RTE_EXEC_ENV_BSDAPP > > @@ -379,6 +381,11 @@ fs_find_next(struct rte_eth_dev *dev, > > return &subs[sid]; > > } > > > > +static inline struct rte_eth_dev * > > +fsdev_from_subdev(struct sub_device *sdev) { > > + return &rte_eth_devices[sdev->fs_port_id]; > > +} > > + >=20 > Using a static inline that already enforce parameter type makes the > _from_subdev suffix redundant. >=20 > I think >=20 > fs_dev(struct sub_device *sdev); >=20 > would be more readable in most of the changes above, while keeping with > the fs_ prefix used in all static failsafe functions. >=20 I think you are right if I'm only reading the prototype of the function/imp= lementation. But, if I'm reading it from the function call, it would be easier to read/u= nderstand it. I would change the prefix to be fs_dev_from_subdev instead what do you thin= k? > > /* > > * Lock hot-plug mutex. > > * is_alarm means that the caller is, for sure, the hot-plug alarm > mechanism. > > -- > > 2.7.4 > > >=20 > -- > Ga=EBtan Rivet > 6WIND Kindest regards, Raslan Darawsheh