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 9A83BA0540; Tue, 14 Jul 2020 16:21:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 548251D554; Tue, 14 Jul 2020 16:21:18 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60048.outbound.protection.outlook.com [40.107.6.48]) by dpdk.org (Postfix) with ESMTP id B4D521D52B for ; Tue, 14 Jul 2020 16:21:13 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hqSABzX2d8EpOL4ZQdJz2xUdELICd+LH5rllqfYbQ0YzkQs/azVlwx+6f26omuT1mLAQMBxunwuEkBo6nzl1gUwbmnnv2sN0SGly4XV1Vdw6oukuoCcGLTY/HACREacWXbfUcN5uYFVK77ToPTuyClWie02ehViTkZaf2IZLet+qJ1dMUT1R7ilDjimoVG8sT5RrVs4UX2Ny0G9tdo4aTiruvdlPw8pzE8pOFiVF0sLdFq8P5n/LcTnc438x3Ft0KDkb3FQzEaDp5apS+mKmJVmAppCr8bc7VvhBY85rWWPKNe+qfKSMnf/hlDLKMgVe4T4GyVsPqIRQ2IXWDN0ofA== 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=Ok9bjGN0a1N/zG6iWBJx0vnoCklVjWJevw36zomYEzE=; b=YK3HnOhRNb4vY+EK+iYyyCZ8Zy9Xfiq/QQjy4Wn1Z7S4nRiB9ecYok2bjmpaHAnzhxJj8tuAY8ECCzCaVNv0Oa+f8z2AHbKToPFHfdMbn9fqYtri9EK6FzBAqk65HXXIMhvvSF8uoIdDrHkDNHNbYGhbw2IgRSz3Q7leiqlgVuBFVFoQR8l0qqTVRXJWlS7wAPYijoLA2tbfAQj/YcHjWthHtowGD/xJmU7bqtTsRBBOlPEJqLbWuaYR/nqkjdeSFUZ9d5VqGPEejHLOa/+tn7RUgjpazHbf3T4gjKYpTAGuVMIdDIhsQPgNUSYBu5Ja7WHG9luHVsq4BhBXOLuO0w== 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=Ok9bjGN0a1N/zG6iWBJx0vnoCklVjWJevw36zomYEzE=; b=C54dFCd6x28AEc+6lVPsYGiYXVxGNyqkFNTfE2yiKnAk489Tr7W3kZRytGeAvCDO7eH/WfVbL5JmIKzeb9uup5gIJFu7qY4OCoXyx6/XKSvcSXJIROzoAO1ey2b6sMSjmH6NSPMthfdMZuOkql9c0/X3COEZznTbsn8LNfsWDpw= 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 AM0PR05MB4625.eurprd05.prod.outlook.com (2603:10a6:208:b6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.24; Tue, 14 Jul 2020 14:21:13 +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.3174.026; Tue, 14 Jul 2020 14:21:13 +0000 From: Ophir Munk To: dev@dpdk.org Cc: Raslan Darawsheh , Ophir Munk , Matan Azrad Date: Tue, 14 Jul 2020 14:20:58 +0000 Message-Id: <20200714142102.30606-5-ophirmu@mellanox.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20200714142102.30606-1-ophirmu@mellanox.com> References: <20200714142102.30606-1-ophirmu@mellanox.com> Content-Type: text/plain X-ClientProxiedBy: AM3PR05CA0100.eurprd05.prod.outlook.com (2603:10a6:207:1::26) 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 AM3PR05CA0100.eurprd05.prod.outlook.com (2603:10a6:207:1::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Tue, 14 Jul 2020 14:21:12 +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: 95fd75ce-0d42-4b75-a93a-08d828012965 X-MS-TrafficTypeDiagnostic: AM0PR05MB4625: 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: s8gjuj+I7lJUl58P8SN2B0NcvgEziintTT76pWo/Wo50KbeBnngsFm/BJFmI1di2HZR9b2ZUoIfDyUVoBzhaBeVAme+OwrFS9JASDZeN0d2QJgvEe4NWRGGlC3zjgIRsIZdTKBis1KDqwPB4WhSh3P1Bn/sZhZjE/Kvg0xYkWPyJpESOuK4R5rJFCOobsRCRFecpDcTcSff1bh9G/PFKSH+0MgEK3hrlYmDw73AULqIuHNMRJReNo6MxE/ZOuK+rzxqUzHKoiaTOfsMbrhYkajTxjSyJqgPqf39t9TUKO9cEhFM+q8ldRjGZhlC2maF/dINKFlf4Z1BCEA3Gs48Zry+/wtacVC5Z+7K+JUcsFhnRGHEn1G2FSI1RkZi11/OF 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)(136003)(366004)(376002)(39850400004)(346002)(396003)(36756003)(86362001)(1076003)(8886007)(6666004)(66946007)(316002)(66476007)(52116002)(7696005)(5660300002)(26005)(66556008)(54906003)(478600001)(6916009)(83380400001)(16526019)(8676002)(8936002)(4326008)(956004)(2616005)(107886003)(2906002)(55016002)(186003)(309714004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: EMszFOwxvt42vd5ogCt0tjzwIuIs1rPA+E+8xePCVz7Xlbk4DTPl1ZUCSx/vY+1U4IDoSID4pd0wkdpW2MgOOATa2V7XU4DFypjrANKF5TJqRL2OWvIfE20rKOqEitV6GXc5Y7X3HzKMsIr+isG2Rhjbk8t2fZgJ0z1NP4sT2IDeih8oaI+dHVnGWdZ2KpxLp19k8XjZFyArHQhREqIqDfXpNerLrD84plG7FLTFSp+QKHA4hvqqrjgtEMtThwwtMClaRJF68eCdwo3y1Ds2/ofL0nvTm9XQcTLm0aaZSaDi6xFxg9KIiIfCn583Vbyy8gBbCNWi39ewFGeJOPxVahbPBK0INh50BjxbPiS31iJGiPoD/8lWh1XaOVqCnlbsqXkNwULj1WqsaoI9UfbcuZvL5fMzBnO+Dv94y69RXFYnGcGjWPJwMTS6KqfCmbui26fY0Dmofh8844eFCDAgLxqeb61oDPr+aEjbb5ArfoxJNF92XhTPc8ympqGV1nm/ X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 95fd75ce-0d42-4b75-a93a-08d828012965 X-MS-Exchange-CrossTenant-AuthSource: AM0PR05MB4209.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2020 14:21:12.9450 (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: OzsiNWtyCx2/x9Dmywr+lU7cK76LbEqHj6SMSyniotDU77xaSkh2nsWObnu2OhyhCDzK1Wskil2VYOeRzLMFQg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4625 Subject: [dpdk-dev] [PATCH v1 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 b5993a7..7de57a4 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -2371,6 +2371,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 bf1d97a..f719cfc 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -945,4 +945,6 @@ 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); #endif /* RTE_PMD_MLX5_H_ */ 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