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 E84FFA0679 for ; Tue, 2 Apr 2019 21:09:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8106F5F1D; Tue, 2 Apr 2019 21:09:48 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20050.outbound.protection.outlook.com [40.107.2.50]) by dpdk.org (Postfix) with ESMTP id 8DB115F1C for ; Tue, 2 Apr 2019 21:09:46 +0200 (CEST) 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=AXuF+DCfKXILe3zSFDvdaNRza8lgZTGioRmPHkZESnc=; b=OAbcPj+kBm1mvH9c5UeKnjOOmci8gBhmjodShv7sbUbG7F3gNpI5CLOCLV9h3bJXrNiNqToxt51XKfeP04rljhAr1OrUTDqAjUi5aUVxOVuDxzyqXBCggYJinIfNX5bk9Fnyc+lJJFJ6B3xzboccDt/295exO/yJp07p/WYDH7Q= Received: from AM0PR0502MB3795.eurprd05.prod.outlook.com (52.133.45.150) by AM0PR0502MB4050.eurprd05.prod.outlook.com (52.133.37.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1750.20; Tue, 2 Apr 2019 19:09:45 +0000 Received: from AM0PR0502MB3795.eurprd05.prod.outlook.com ([fe80::84f3:7e92:7a51:1003]) by AM0PR0502MB3795.eurprd05.prod.outlook.com ([fe80::84f3:7e92:7a51:1003%2]) with mapi id 15.20.1750.014; Tue, 2 Apr 2019 19:09:45 +0000 From: Shahaf Shuler To: Slava Ovsiienko , "dev@dpdk.org" Thread-Topic: [PATCH 1/4] net/mlx5: add DV/DR flow data alloc/free routines Thread-Index: AQHU6Rx9GPy83Zaw80qDIGuBCUMf3qYpM1aw Date: Tue, 2 Apr 2019 19:09:45 +0000 Message-ID: References: <1554186157-29455-1-git-send-email-viacheslavo@mellanox.com> <1554186157-29455-2-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1554186157-29455-2-git-send-email-viacheslavo@mellanox.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=shahafs@mellanox.com; x-originating-ip: [31.154.10.105] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 09806c7e-db45-4607-cf65-08d6b79ec4a3 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600139)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:AM0PR0502MB4050; x-ms-traffictypediagnostic: AM0PR0502MB4050: x-microsoft-antispam-prvs: x-forefront-prvs: 0995196AA2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(396003)(39860400002)(376002)(136003)(366004)(189003)(199004)(97736004)(55016002)(71200400001)(68736007)(14454004)(9686003)(53936002)(26005)(6116002)(6246003)(71190400001)(6506007)(3846002)(99286004)(476003)(446003)(186003)(76176011)(2501003)(6436002)(7696005)(52536014)(11346002)(102836004)(486006)(305945005)(106356001)(33656002)(316002)(7736002)(110136005)(14444005)(86362001)(229853002)(74316002)(66066001)(105586002)(5660300002)(81156014)(8936002)(81166006)(25786009)(2906002)(8676002)(256004)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB4050; H:AM0PR0502MB3795.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: SIeA04FMsHeTRjumqkCUmAL7as3dmazBhHipw5BfD44c8Hfuf9Qe8MAz6ZakDP/pvp/mWMEPhBbTbGzmqRO9NYuStTFMAC7mhGdmVmgUOvpaCdpjqPwxeGN7bfnWVZnycQ8v6nMP50TiW0o60Gl/GTT3y0I7pRwhAuSjmQxRWfWGOniMYcXtxL36t6S3p8KovN328D54qoD3Z308SML3ZksmhYTTd+TabFa8bfwAr9JzhcNZpqpfyhKGfjrrumx0oIK1HEfcw0hTFiVJulEZgvu9lOjR6PfM3mWyplLTZUjbLDQp9OsrzD/0+pshaaB69Vo+vnaNAO1+7UVoHYlsOosQl7jtbO3wO9G/rScwpIvKwq+WoaVywHfnjPt3XesXqVWe0ecNvVymf6Dr05ASc13oXOnFIO7+BcLPrzKoZIM= 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: 09806c7e-db45-4607-cf65-08d6b79ec4a3 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Apr 2019 19:09:45.0418 (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: AM0PR0502MB4050 Subject: Re: [dpdk-dev] [PATCH 1/4] net/mlx5: add DV/DR flow data alloc/free routines 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: <20190402190945.3sPqQLd4AIwzqPv3bjr3wzLHRkpanXXE3nLsF3LB_4M@z> Tuesday, April 2, 2019 9:23 AM, Viacheslav Ovsiienko: > Subject: [PATCH 1/4] net/mlx5: add DV/DR flow data alloc/free routines DV and DR are acronyms which are Mellanox specific. The title should be wri= tten in a way that even non-Mellanox developer will easily understand it.=20 >=20 > We are going to share the DR/DV flow device data structures between > master and representors in the E-Switch configurations over multiport IB > device. >=20 > The code of initializing and destroying these data is moved to dedicated > routines, this is just a preparation step for actual data sharing. >=20 > Signed-off-by: Viacheslav Ovsiienko > --- > drivers/net/mlx5/mlx5.c | 90 > ++++++++++++++++++++++++++++++++++++++++++------- > 1 file changed, 77 insertions(+), 13 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index > b59fc58..9de122d 100644 > --- a/drivers/net/mlx5/mlx5.c > +++ b/drivers/net/mlx5/mlx5.c > @@ -296,6 +296,73 @@ struct mlx5_dev_spawn_data { > pthread_mutex_unlock(&mlx5_ibv_list_mutex); > } >=20 > +#ifdef HAVE_MLX5DV_DR Function prototypes should not be under ifdef. Ifdef should be used in the = function body. It much simplify the code readability of the function which calls them.=20 > +/** > + * Initialize DV/DR related data within private structure. > + * This is preparation step for the data sharing. Per my understanding below those are only direct rule objects. > + * > + * @param[in] priv > + * Pointer to the private device data structure. > + * > + * @return > + * Zero on success, positive error code otherwise. > + */ > +static int > +mlx5_alloc_shared_dv(struct mlx5_priv *priv) { > + struct mlx5_ibv_shared *sh =3D priv->sh; > + int err =3D 0; > + void *ns; > + > + ns =3D mlx5dv_dr_create_ns(sh->ctx, > MLX5DV_DR_NS_DOMAIN_INGRESS_BYPASS); > + if (!ns) { > + DRV_LOG(ERR, "ingress mlx5dv_dr_create_ns failed"); > + err =3D errno; > + goto error; > + } > + priv->rx_ns =3D ns; > + ns =3D mlx5dv_dr_create_ns(sh->ctx, > MLX5DV_DR_NS_DOMAIN_EGRESS_BYPASS); > + if (!ns) { > + DRV_LOG(ERR, "egress mlx5dv_dr_create_ns failed"); > + err =3D errno; > + goto error; > + } > + priv->tx_ns =3D ns; > + return 0; > + > +error: > + /* Rollback the created objects. */ > + if (priv->rx_ns) { > + mlx5dv_dr_destroy_ns(priv->rx_ns); > + priv->rx_ns =3D NULL; > + } > + if (priv->tx_ns) { > + mlx5dv_dr_destroy_ns(priv->tx_ns); > + priv->tx_ns =3D NULL; > + } > + return err; > +} > + > +/** > + * Destroy DV/DR related structures within private structure. > + * > + * @param[in] priv > + * Pointer to the private device data structure. > + */ > +static void > +mlx5_free_shared_dv(struct mlx5_priv *priv) { > + if (priv->rx_ns) { > + mlx5dv_dr_destroy_ns(priv->rx_ns); > + priv->rx_ns =3D NULL; > + } > + if (priv->tx_ns) { > + mlx5dv_dr_destroy_ns(priv->tx_ns); > + priv->tx_ns =3D NULL; > + } > +} > +#endif > + > /** > * Prepare shared data between primary and secondary process. > */ > @@ -446,6 +513,9 @@ struct mlx5_dev_spawn_data { > mlx5_mprq_free_mp(dev); > mlx5_mr_release(dev); > assert(priv->sh); > +#ifdef HAVE_MLX5DV_DR Have the ifdef inside the shared_dv and remove it from here.=20 > + mlx5_free_shared_dv(priv); > +#endif > if (priv->sh) > mlx5_free_shared_ibctx(priv->sh); > priv->sh =3D NULL; > @@ -1363,20 +1433,11 @@ struct mlx5_dev_spawn_data { > } > } > #ifdef HAVE_MLX5DV_DR > - priv->rx_ns =3D mlx5dv_dr_create_ns > - (sh->ctx, > MLX5DV_DR_NS_DOMAIN_INGRESS_BYPASS); > - if (priv->rx_ns =3D=3D NULL) { > - DRV_LOG(ERR, "mlx5dv_dr_create_ns failed"); > - err =3D errno; > - goto error; > - } > - priv->tx_ns =3D mlx5dv_dr_create_ns(sh->ctx, > - > MLX5DV_DR_NS_DOMAIN_EGRESS_BYPASS); > - if (priv->tx_ns =3D=3D NULL) { > - DRV_LOG(ERR, "mlx5dv_dr_create_ns failed"); > - err =3D errno; > + if (config.dv_flow_en) { > + err =3D mlx5_alloc_shared_dv(priv); > + if (err) > goto error; > - } > + } > #endif > TAILQ_INIT(&priv->flows); > TAILQ_INIT(&priv->ctrl_flows); > @@ -1429,6 +1490,9 @@ struct mlx5_dev_spawn_data { > return eth_dev; > error: > if (priv) { > +#ifdef HAVE_MLX5DV_DR > + mlx5_free_shared_dv(priv); > +#endif > if (priv->nl_socket_route >=3D 0) > close(priv->nl_socket_route); > if (priv->nl_socket_rdma >=3D 0) > -- > 1.8.3.1