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 A53A8A0540; Sun, 19 Jul 2020 12:19:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 369061C0D6; Sun, 19 Jul 2020 12:18:37 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2061.outbound.protection.outlook.com [40.107.22.61]) by dpdk.org (Postfix) with ESMTP id EF9071C06D for ; Sun, 19 Jul 2020 12:18:29 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X2hihNlrDVFb7wzFsNh01OOHNjCG62aNz36a/IfIY7xbORxv+ICDOrZ1bX/Nwq/7bQSyaJL2dWf25ezQ3pTYeSyWqYRsXmmlCmjpwIyLBC70ZY5eiEoneuRdoPof6NRgY0+5PA9co5HX2p7+fTzLq/+4EhdJlxWDfBd+Hcuc8QgwjI0sUSD9A5dKLs1RHjLaaL83fpNzdhgcyLzB46nroymM7sdteoTjYelh5vtaVulId3tKPs0lqzt16lLlHI87nsys+QbcofwY1lWoO32etLhhj7MTFUAXKn0w8SqtRqHQBI2zffQkJIt+ggBI5VNP66wiyzrT+YsKg7l6dHLWaA== 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=1vyGGeIxWil81EUmBuYSkD57iZKE2xbWDVFp/cKWhpw=; b=Ju7T0qR63f3BUd+uMqqnaAAuuoz+2S9FKKJLUMffNTMtR7DLFlY0jxlhb12ez8mO9hUenrzanT1pOK5FqrUFYpB3Zqo55ytsbiDHE5g9NszKSx1OzM7TiuBWdtRe6jSRF9r5+fJVCyZB7Yq+xG2bWjKhSWIdWU3yf4u80w6xL4sDF+VWa4qqFeY7qq4VxvPuLHo31Qgw5fFu2cE6ErLGsNrjAXIFa0TSUpUW5vi9vBU8c4iEyic2XUkF5qABWmCjH29xsDa1eP9M/layWq7hwr1X7/Gj2SkF6STiC6+QCvwuvHMEko7f0IFJwB0JZrtp/Zc4ZwuESGX1bdEYXamzsg== 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=1vyGGeIxWil81EUmBuYSkD57iZKE2xbWDVFp/cKWhpw=; b=XG7APbhJfyUmvrCKdIdGxglRdmrXhnTZweI7W5L7g2q2Tq5ZVHAxY576+14Kwau7oK5tmegcjz6xmzA598nWBgKe05v62AqyG+tY86S1048cmN+xAlKZytFMq9F2BRA2l2dpE8zCeTGvE0wWrHTFyrq/b8GnhOaByLnBrWTwd4g= 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 AM0PR05MB6324.eurprd05.prod.outlook.com (2603:10a6:208:143::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.25; Sun, 19 Jul 2020 10:18: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 10:18:29 +0000 From: Ophir Munk To: dev@dpdk.org Cc: Raslan Darawsheh , Ophir Munk , Matan Azrad Date: Sun, 19 Jul 2020 10:18:12 +0000 Message-Id: <20200719101816.16406-5-ophirmu@mellanox.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20200719101816.16406-1-ophirmu@mellanox.com> References: <20200719071112.8540-9-ophirmu@mellanox.com> <20200719101816.16406-1-ophirmu@mellanox.com> Content-Type: text/plain X-ClientProxiedBy: AM0PR05CA0090.eurprd05.prod.outlook.com (2603:10a6:208:136::30) 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 AM0PR05CA0090.eurprd05.prod.outlook.com (2603:10a6:208:136::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.18 via Frontend Transport; Sun, 19 Jul 2020 10:18:28 +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: 411a297a-2192-4c62-ca8e-08d82bcd14bf X-MS-TrafficTypeDiagnostic: AM0PR05MB6324: 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: cztkEIPVUFOxkR5x8e+HndXoS1qvCT6LlBfJVCOP47NipGOuMx+VPrgFJql50H2xzhuYvu3KgsRaxxIWgjLMU7CDVnTwNplvnSpF+HLcYPzC7ljVGPR+B0BX0VWe3JiOVwuVbEBgk+5MReghOjrNX3YKjYBJw5tQoLbNSQO2qZj7wdyVu41UIulPTUkbfGOJDcfQMnyGAaBPMr56Tpb0qx6fofeztHErDwaGdAwcmropOicopj3rsRvWTgVRye1EmfNmcMOyinwAHQqg6klRzryn0+8imChWMguVOy+6RqT+/a8H223DTqi/GdpPKGeKnl4Y2JsOU717/24CVafSlLQ6o3YVfAo2QC1R2UzmbD4SyByt1pyDnCZpfB9ui+BW 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)(346002)(376002)(136003)(39860400002)(366004)(5660300002)(316002)(2906002)(36756003)(54906003)(186003)(2616005)(6666004)(16526019)(4326008)(83380400001)(956004)(6916009)(26005)(478600001)(52116002)(7696005)(107886003)(66556008)(86362001)(66476007)(66946007)(1076003)(55016002)(8936002)(8676002)(8886007)(309714004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: iYNqmDYgO4dEnHrPKNwJtO9JXwlJeVmTRtP4wdZuqLezYa8MUJswOZI2sKmQM+joHyA9rQrzsifORr/0xWlImlnxP64N+PRN4hDUfiNvEWa2okb7M4nsfJ+/ulspMAC11LQmZFKi6C41umC51TDW0SSxs/9o0GcqtzpxIW4Xtjac10w+NPKSiKh1rPYrOkpuUW+ceY4VfIz+YR268XjQOJkvbfLaP4R2x2qe+ij0gD8LxRR5SVpE1upZvPAlzLuQIOvl8zWnbtdlKcLaKNaoWzvIgUAKIEUnGCPpr6RUd02eBSF1d1OOR94vRrr23CXW4LBFNPGwTu+63YWNyy5RbijclGi7n73HgXElIIMxy08ur9S7oL3nKyXCgATjzHw7lFD2z2Q2ae94Hra1uP0DKcKRVhkNHf1ujGKaHHTJ5ozHBa/xEgls9yQDgWMNg+7qfam1LKMhqjs7YvCaFA1IkHmr8gVajoxW1XTgpZBvSEblxA4hXUhrbTR1yPjbh5t5 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 411a297a-2192-4c62-ca8e-08d82bcd14bf X-MS-Exchange-CrossTenant-AuthSource: AM0PR05MB4209.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2020 10:18:29.1557 (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: BKoN8grHrRiwuV7sJG2ZmHZV5jBBx3jozK7OvJyqEW+sl07VI5Ze/f/PXRuxvFCmVQT3HOI6mFdv0a+jSSnDFw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB6324 Subject: [dpdk-dev] [PATCH v3 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 9a35ccc..1f82f0a 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -2456,6 +2456,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 a3c7824..24a668b 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1030,6 +1030,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