From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7D2E5A052A; Sun, 19 Jul 2020 09:12:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B9A881C07D; Sun, 19 Jul 2020 09:11:35 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60057.outbound.protection.outlook.com [40.107.6.57]) by dpdk.org (Postfix) with ESMTP id C38301C02A for ; Sun, 19 Jul 2020 09:11:30 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LdjR9SmLCVZQFZoPDbhK7t4nouDXgMYT2DHs+ASr7539p7LM8oR8dWU/Ml32QNf2jgf61FKseXlKebXGNTPU4if0QTCwre9SePznya5GVsKVVavRmZNZePsqzvp/LTugsfhMWYucmqVDUfZCHLoFLzbqYcCN0Z9phZYQ4WM7dGLPwoQghz2LAa0iGHKK5Hg6PaCEGyVZJvi4sRGlBh7ci+MH/mFP1IzfzQGMSG3AiEluoZazDTbJ48jY/bq1TzMkeG8vSX7cWuu0cC2pAqEpRMz6R6ch8YswwbBuvpb45+QJLS38LEG4JTlipMTvn9SExEEJ0f+qjYYHNmY83K4Kfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8SB2wgg72AgIJxBNg4i0TdN+TuMtkqdx5GQhEejy5LI=; b=XyqXGZsPdD/TLW0Unm6IXS/FxZaKPc+SlGFNrdCH2MHYfAp7UYVXRNP+/2M7EFn3g7XeIkLaFuGlzxrmIbUiH9v4qL0WI29z7D7f5IQlF3+1C0N7pngS93EOo/nOEGOGAOz2KJsMmiBfxxJv1rWXflSKrSgL0Gh0fHh/zOYcOzk8pGxzxkn3w3rsySWcUxwKjN3HbQ7jmUT21Pq5YZQLvC1uhKMpwocfjZW04mKm1s0pcs8Y6IxMJYkCHEsGHvYRO3cuos5Wu+3o1ebJ7gP1rqBQ778oH0co+aD8At7zqZSlNtzi6iF0btulbPbiRGGZuS5f6TwE5HI9mgGeyZUFEA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none 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=8SB2wgg72AgIJxBNg4i0TdN+TuMtkqdx5GQhEejy5LI=; b=GqOttn6rriLCDuw3FYMzUE3mMYv8a9VKsqfLgraGGG2kAvYgseBB5kleGHPGPxXycHcsoyRx38pxN4CsHlbvFR7wOE4McCLZGi3bfVd9z48jdvhS1CTJVpwZGcNKJojnWpZltKFucrVK/e1JjVI2WTp+43nOrZAsvCAJxGRvIIE= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR05MB4209.eurprd05.prod.outlook.com (2603:10a6:208:61::22) by AM0PR05MB4738.eurprd05.prod.outlook.com (2603:10a6:208:b7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21; Sun, 19 Jul 2020 07:11:29 +0000 Received: from AM0PR05MB4209.eurprd05.prod.outlook.com ([fe80::3949:70c3:126:3972]) by AM0PR05MB4209.eurprd05.prod.outlook.com ([fe80::3949:70c3:126:3972%7]) with mapi id 15.20.3195.024; Sun, 19 Jul 2020 07:11:29 +0000 From: Ophir Munk To: dev@dpdk.org Cc: Raslan Darawsheh , Ophir Munk , Matan Azrad Date: Sun, 19 Jul 2020 07:11:08 +0000 Message-Id: <20200719071112.8540-5-ophirmu@mellanox.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20200719071112.8540-1-ophirmu@mellanox.com> References: <20200714142102.30606-9-ophirmu@mellanox.com> <20200719071112.8540-1-ophirmu@mellanox.com> Content-Type: text/plain X-ClientProxiedBy: AM0PR04CA0024.eurprd04.prod.outlook.com (2603:10a6:208:122::37) To AM0PR05MB4209.eurprd05.prod.outlook.com (2603:10a6:208:61::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mellanox.com (37.142.13.130) by AM0PR04CA0024.eurprd04.prod.outlook.com (2603:10a6:208:122::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.17 via Frontend Transport; Sun, 19 Jul 2020 07:11:29 +0000 X-Mailer: git-send-email 2.8.4 X-Originating-IP: [37.142.13.130] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6bca5e59-7f2b-4e2d-5c73-08d82bb2f581 X-MS-TrafficTypeDiagnostic: AM0PR05MB4738: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtFwd X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:93; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8sYGsfXw87lHpvRzC8aKeRaYM4ZT34JBHepu/T4bMqaf0E5fg+kCtXmx9EIPL9TXaizMEP2IutDh4tawmyAgOC1LhIv5UMtuQztHoLz2VQNM1OQewNvIrUE1xhYU12iXe4m50VF6V+QD8+ZPy+rfmDLnBrXpPXic+jP8M0vdZEcBOKsuwojHYk+ZSnJczdiar1FQkn1KM/S4pd1Owgk9X2vT/XdRlw8JtjAWhWKcYz2Fte+8Z70oGpfhw7aZh+Epa0zv0Ve0R2OReXe2Yjx8XfHsOe0VS6dsd/ZkyEOkXJycXxUNYAq872e4/os9Ffm7zk3tQB250CpcyTxQgBhpPGezRXcoj+ZVHaU+lQRZ6wg6fheFSdluX8vfQvYezTah X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB4209.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(376002)(39850400004)(346002)(136003)(366004)(52116002)(107886003)(5660300002)(2906002)(316002)(36756003)(8886007)(6666004)(7696005)(6916009)(55016002)(8676002)(478600001)(2616005)(4326008)(66556008)(66476007)(186003)(26005)(66946007)(54906003)(83380400001)(1076003)(86362001)(16526019)(956004)(8936002)(309714004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: AmR5HpB59hDxfPijJDfWs8LxkuIG2P4nHG21eYf7YvTBBx33LxZ7iitxAF9lE1Xy+2IzpY06RADp4yCXk3HjiSk/qbZOPfaEYtvmI1asqba2c5pomR5cxPiyvXzluzKhoSLh1SMLXUkKrsl+AfsaekWRGB+GU/grgDg7mtj9TLKfqdrVIU9CuqDqtlde7UgAA85madMlAHSy2ZVx4IKnheJ9YEMVfiBx9Ne5LGg5qaZhXdkpn/SDmW1TdxUkyLJGeZ6aMqquKKvQX/pMeWFn/fR5QmeCS9xwo1L55rgVbTTOOHf/rNggIIZCVd5CIYAq2DbeeFMdDygo0eyFX5AedRFN0Q8+qjnp8nc6hk6u4QAfK3k8eL1Ay64s3pRtiUsTQnfrA9TJ+IG2d4zLugBCobDxZsR6rB5kdellKmcCvXaUUxOMsEniNAFgv0MrgE0wn1bae4XSa7VbSs3ih0Zo5PHJ0pGgkqnTpMJKz1GWMCnX2jNoaZ7Mtv+ODrPWrtLS X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6bca5e59-7f2b-4e2d-5c73-08d82bb2f581 X-MS-Exchange-CrossTenant-AuthSource: AM0PR05MB4209.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2020 07:11:29.8072 (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-CrossTenant-UserPrincipalName: wPZz9MJQyA2L9X/u7OnPaCEDS6FjRn3lZKaLhN4P4+cEmVc4tZ3nKtLrSVEg3rR42x6DpVGmHfvtlaiUUzhD5g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4738 Subject: [dpdk-dev] [PATCH v2 4/8] linux/mlx5: add setters for promiscuous and all-multi 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" This commit adds Linux implementation of routines mlx5_os_set_promisc() and mlx5_os_set_promisc(). The routines call netlink APIs. Signed-off-by: Ophir Munk Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_os.c | 40 ++++++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5.h | 2 ++ drivers/net/mlx5/mlx5_rxmode.c | 12 ++++-------- 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index fda2233..14fffe3 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -2448,6 +2448,46 @@ mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv, (priv->nl_socket_route, iface_idx, mac_addr, vf_index); } +/** + * Set device promiscuous mode + * + * @param dev + * Pointer to Ethernet device structure. + * @param enable + * 0 - promiscuous is disabled, otherwise - enabled + * + * @return + * 0 on success, a negative error value otherwise + */ +int +mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable) +{ + struct mlx5_priv *priv = dev->data->dev_private; + + return mlx5_nl_promisc(priv->nl_socket_route, + mlx5_ifindex(dev), !!enable); +} + +/** + * Set device promiscuous mode + * + * @param dev + * Pointer to Ethernet device structure. + * @param enable + * 0 - all multicase is disabled, otherwise - enabled + * + * @return + * 0 on success, a negative error value otherwise + */ +int +mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable) +{ + struct mlx5_priv *priv = dev->data->dev_private; + + return mlx5_nl_allmulti(priv->nl_socket_route, + mlx5_ifindex(dev), !!enable); +} + const struct eth_dev_ops mlx5_os_dev_ops = { .dev_configure = mlx5_dev_configure, .dev_start = mlx5_dev_start, diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index ac72e9c..afc0e83 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1029,6 +1029,8 @@ int mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac, int mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv, unsigned int iface_idx, struct rte_ether_addr *mac_addr, int vf_index); +int mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable); +int mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable); /* mlx5_txpp.c */ diff --git a/drivers/net/mlx5/mlx5_rxmode.c b/drivers/net/mlx5/mlx5_rxmode.c index 84c8b05..80b1256 100644 --- a/drivers/net/mlx5/mlx5_rxmode.c +++ b/drivers/net/mlx5/mlx5_rxmode.c @@ -47,8 +47,7 @@ mlx5_promiscuous_enable(struct rte_eth_dev *dev) return 0; } if (priv->config.vf) { - ret = mlx5_nl_promisc(priv->nl_socket_route, mlx5_ifindex(dev), - 1); + ret = mlx5_os_set_promisc(dev, 1); if (ret) return ret; } @@ -81,8 +80,7 @@ mlx5_promiscuous_disable(struct rte_eth_dev *dev) dev->data->promiscuous = 0; if (priv->config.vf) { - ret = mlx5_nl_promisc(priv->nl_socket_route, mlx5_ifindex(dev), - 0); + ret = mlx5_os_set_promisc(dev, 0); if (ret) return ret; } @@ -122,8 +120,7 @@ mlx5_allmulticast_enable(struct rte_eth_dev *dev) return 0; } if (priv->config.vf) { - ret = mlx5_nl_allmulti(priv->nl_socket_route, mlx5_ifindex(dev), - 1); + ret = mlx5_os_set_allmulti(dev, 1); if (ret) goto error; } @@ -156,8 +153,7 @@ mlx5_allmulticast_disable(struct rte_eth_dev *dev) dev->data->all_multicast = 0; if (priv->config.vf) { - ret = mlx5_nl_allmulti(priv->nl_socket_route, mlx5_ifindex(dev), - 0); + ret = mlx5_os_set_allmulti(dev, 0); if (ret) goto error; } -- 2.8.4