From patchwork Thu Nov 30 11:46:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 120140 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp558109qgn; Thu, 30 Nov 2017 03:47:14 -0800 (PST) X-Google-Smtp-Source: AGs4zMYQASjeylsB67bLZpm8y3KHSRjNhxty5YsxciHJ1mZTBnKRkaphum6JR4eAjU5s6kduqGuC X-Received: by 10.223.190.135 with SMTP id i7mr1732596wrh.91.1512042434829; Thu, 30 Nov 2017 03:47:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512042434; cv=none; d=google.com; s=arc-20160816; b=FMXr1IF9tfQ7li2QADgty05xtRCCj+Z3n9jkuQuNOQ9R6hpqEEUhQl2Zzuxj4E09mv 7yB18Ub3fP+r2NfP7XhFKdXG9BzcLe8o9rKI6dtCKGbcP+kKG6ScVhTZm9gQ8E7CJbis teEQiRQjEw5pBkrXLtRSjd6xIgfTMls4AUcN13UaMdUfAxP+B6zbIkALxJ95ZvYR3rxK FTkfrDZfKrvg9krAgajK/zfAduuDrzWju22M+iushmfWhiq85CUEiwZZfvgXb//BkKQD azg+41uBT1eR4D0PcIoQW9aHz3BnbHM48/xnsom2Zw1kgEoc55kJlf6VIxQTjcSyIrCQ MDFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=AQ68SVuBj/T9OyZVfYmF0DwCXiHShsMXW0twxBec6+Q=; b=S7cByQwlZsp35SaiK5YV0M4CN9cmre0tQzxuaO7I5APBH6A1B7+h2++7HMp7vAMa/C 1XL790fyExgpoIveWHzJVFi0ZIL0+wcer2Lnf1YndB4Gs1wcX624213YuPpfHVYkas4H 4hsMjFUP+sZuYOnYqOZgwn93Uw3ua2vpCEaYR+hsEducvDBkGJqUBBXNzjr6f4sjCyim eA3+9WbAQ332FZ5vf0vLBHKwI9ROgbJBLlny1V7HMRjUAjdj43EmzYa28gNxJL7CjxZx W25BJYYLQeYC/sbTXbgiDfSHkkgfxyDfHIKNq3ZIThrJpOCC4HyU9I29V33XfRHljcVy 46SA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id q124si3010528wma.132.2017.11.30.03.47.14; Thu, 30 Nov 2017 03:47:14 -0800 (PST) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CDDB5324B; Thu, 30 Nov 2017 12:47:08 +0100 (CET) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0085.outbound.protection.outlook.com [104.47.34.85]) by dpdk.org (Postfix) with ESMTP id C41EC2C54 for ; Thu, 30 Nov 2017 12:47:05 +0100 (CET) Received: from BN3PR03CA0116.namprd03.prod.outlook.com (10.174.66.34) by CO2PR03MB2359.namprd03.prod.outlook.com (10.166.93.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.282.5; Thu, 30 Nov 2017 11:47:04 +0000 Received: from BY2FFO11OLC014.protection.gbl (2a01:111:f400:7c0c::106) by BN3PR03CA0116.outlook.office365.com (2603:10b6:400:4::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.282.5 via Frontend Transport; Thu, 30 Nov 2017 11:47:03 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; intel.com; dkim=none (message not signed) header.d=none; intel.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11OLC014.mail.protection.outlook.com (10.1.15.48) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.239.4 via Frontend Transport; Thu, 30 Nov 2017 11:47:03 +0000 Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id vAUBkx6x031415; Thu, 30 Nov 2017 04:47:01 -0700 From: Hemant Agrawal To: CC: Date: Thu, 30 Nov 2017 17:16:06 +0530 Message-ID: <1512042367-6361-2-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512042367-6361-1-git-send-email-hemant.agrawal@nxp.com> References: <1512042367-6361-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131565160235032277; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7966004)(336005)(39860400002)(376002)(39380400002)(346002)(2980300002)(1109001)(1110001)(339900001)(3190300001)(199003)(189002)(189998001)(316002)(85426001)(81156014)(356003)(2351001)(50466002)(81166006)(104016004)(86362001)(50986010)(51416003)(76176010)(305945005)(97736004)(53936002)(36756003)(68736007)(48376002)(105606002)(8676002)(50226002)(33646002)(8936002)(4326008)(16586007)(2906002)(77096006)(47776003)(106466001)(2950100002)(498600001)(5660300001)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR03MB2359; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11OLC014; 1:is9365HyaLtYomalCCBD86vGqRIcz3QH7hTknQIhSZTDseYbl5mdDy9wwlWtlmptoR9EAkUdhU4i7Y3NiSyx2rY1fyd8DUhem4LCFFiXuHW+1UdmOHIlt6k2GgpAei+8 MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 173c9e8b-13d6-421e-911f-08d537e812ff X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4628075)(201703131517081)(5600026)(4604075)(2017052603285); SRVR:CO2PR03MB2359; X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2359; 3:qGfM32/I6soczFyzVO2FKiJ59e70fxhVgVZBiDhrpcL0Y+tvVac3a2nBejXmvUVOjV9nfYfjfZK/ngyYNXES8tsPSfG2Xlo1QBB5M+jURxuksBoKAyUahPyNCPwUM9SBI4dBLNuZBBLVAMtcdtG1t09eCohRqajqx+qNks7gwOaLEaCXKNnkBKzmALV1KUvfBEgzGZTXzE7k5/Lc+eNLa1Rk3djZmQYlLeS+SAKDpwZ3I0zOa6AJp3J93RFVcX8zLG/5yLSHBeI1gXw9xjxruXEMZRAA3UM5qCQBXsWs+4ds2DIDzsg7GuRSNjzOWGXPOag6Ec2VsvzS2Z2T/yUbZfzSzAOqqQWYnJUnXMTFdCw=; 25:wl3r/NcrBjD8tl9+EZHE377gLn2obFScCsi2vNewQNVyKFKU3MdpaHYdRslhFCd7PWUyVFnPJ5DDxK0BJLJw2ZR8ERFcUjsEGvaAGusuCvNgHZGJmR2fo8hDEEnsK8KnnP3iRGK+D9FFVfzkkoPGULedt7ENVCeUO9WxV66wQqaHFrfOKKQb586nnr6MxdEOi2aF9nq1Kc3swgsNayac8ZS7eUZuYUx8E2bx49PppMKRZxhiF9dsb3ft+sn+3OS/pFFe4710euqzNUb9kTsdskkI1uX3QMPsWcanvkURda698bpeQKEv6NfIEfUXQ+yqihccFf2fp0I+Jc+T7VFCdA== X-MS-TrafficTypeDiagnostic: CO2PR03MB2359: X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2359; 31:mPbN1jC4nrh3dI1UYchyyjihncN3U2nWMwuyM2FOntCfaYSbW22HMDQlqVnhhhRraCfc5hQVTgqr+n4O2bObhUtvZO8hlQcUA3EzXMsaS6+EerAsfngBafp95nswFsUGVSi5wCvBrEsudUIC9YDY6FuCc+4m4RJiASSo9s36aZnF86973NQc91TS9GdbzXo3VDbghOIfcGUvavO7EAyRa5jX3kuHy6xu/+yU67hVHgw=; 4:LxvPkaM6ukkfNBPxMgMKG08LzQZhLPbfFRSF5y9ryQQsFnkheaZFWR3icKVaa3ernkUBNQKUaOi6G7aF2bdpqJNrScZN7BqPVwQhhzALc33AbVubYl/nnmPyh1WhPoSdo0N7M6wXrWHUvA8LEd20XJX3HxHOkMGPS/IJS1BmaDPMFLkaK9oW+VC2uXaNS79ziHctA+KYYHiCXbPkVrQ/RfQr2j9lYu9Ka84KhHhO3YAeTxrEZXHc7MC6KgPvmioPIaAHPEWnRL2qg7ITUCPWDTkO1YIr5uqx1VQL2PEBR3udGmEqrOlLQrGBQacExCw8 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(5005006)(8121501046)(3231022)(10201501046)(3002001)(93006095)(93001095)(6055026)(6096035)(20161123559100)(20161123561025)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123556025)(20161123563025)(20161123565025)(201708071742011); SRVR:CO2PR03MB2359; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:CO2PR03MB2359; X-Forefront-PRVS: 05079D8470 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR03MB2359; 23:IrmeVR6SR1EJmOdzN+gMGbphLvBz5ov2t+sabF1TH?= RnceiTafp+WAFRLFI08vjJXDYOniHTTKiMeouMHVbBho2HYE/TEVeTIBuBOwqrrL/63rcxLxsYcITpoG6geIW6r4g3UKR+DX1DXfQS9bq2Oww5mMKX69DM8qNiMvHcB4OmBK0EL7kfqYwrq7iICKtI7fjeTKtpYcK5NPS9jnJb+DOqRP+yR7clux1T7mPcM/Lmj0kYoGnvXAG+X7Wn4HXle3Vr9J6F1u9cVLZOrR4cKwS2LAkt+vtmiCIpcz89HqD7Q/7j/IYq+nPHHoTUxs3KJO5m/w7Fl0x5wfPLOYVXYWSMj/79B+NIOH/H/Nf1MjT/tmi6K6MXPFhdgOrDGv+HgBsKcf5LFcC0W9LxP0O9GW6U8xsZjC+AzoeLOpS4rniR4GqwChXGG7V7ySH2bEwmSYhXThZ8cvoQI7/9OXh4FNJ0RO5aqI26epe2fBvluRUQ91MRnXngG5Ob4Tow3abpIxKOhvgKuVHBts310rtTbofgBfQho8jAtOhfePQ7ZyRVhpa+eDbXwWM+4Wg20Jy+2aP+GC4jCN06sWegGpera7ISjk1XiDs7bdV8/Es0cwdZMIXU+DFOCu39Mdxoi9oyDt0pECgh0OjhvT69DUveNpZmQfghBp7RwSEQEc4WGmolo66+nywg0zP68WIetg1IZxdV+akBjbpMes2vUuqury1krch1ZPAomX8PlpYCblasHXL+4ZoGqbfQUoi0qJn9Dv2bL7nK/8UUPq2HduXFy5RoL4xP47nemhMeY+QJxKgSSlxMhDg/dWYWVbEecUYtM0V8JrfEKyK5WUuO/sHMTGS0YEhOcHq3ONk3fxcbKFv/3uy2dTs0NI6r2dPWfWiyEeKDjWHK1b+WZFZzm1F2J6DIWXmyF3evUW6rjwcjUCgMPk2iRvnTHTpI0mjBitUvSc+vzS16nZ2g5aBX+XC/MZoCUNV6//dH+Qgt5orICZs01HH1rCtojU1Osc0fM3492WBkSoPVRM2fxTOgQDG1JFs2iOqptdLBdk9Uv3cMCRolCEHwFj41104bk7Ykby1t2HO/TVwI1Pk8M0WQGHVHLPeGGscvqTBCuOutdzE1mgD2v3b5nT78wJ9coKkp4RXoO X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2359; 6:rKJAXWYDRMK7O2bSpf55cBNlmqZ+Yl0DxEs9ZSlnF2HeCzHw1aSUTd9J+qeyStBg7K93jbJJXu+G4ceKbn10yTPKSapNO5Ci8ARqdG2faV1ghpTAwHNBT7s3v6rzzxoxSNjbcS6mtS548WeZIzWRd5d04b+l064pdFWV/p6kz9avfpDjb7Lo3nCKYS6SC5ft+NTq1SHBM/uFWcFhuhGzPm9Su1o6l1sdRMKZohoA7Jkkc/4ALXbRlb2GJ7F+GonyCV2XhV4y6c4tSy71lIYqHAqQ7mW77QV4pT6WgI01UPTyjiIuJyaWC6hbO+76ilLurtMZw8sygHNn8nILJgLAUC1amVrNOxm+hfJDqiSj9MI=; 5:qbA0gp7vqaJlx5Q2fD7CmXunQzPDtn1Fe8Ru1MKDKSDFc6iv7S51i5yCsJECHgf1fK4hu/RyCLtrcELjJorZSLWN/bXDcSdaGTCE00klsc+CwSy4qnL3kYhSHymvnrPiHf0avh7YOmub9cUZSDlBechfkjQst4h2DEWJAPJiGyE=; 24:FAMqAMDmiV4ANF9S0i6on88W4fIj/0vjbwdxHKHCbOC6P46v1qnKuHDGlMKr5EN9uPJ38p3Z6fxgxMW5VvkniP1qmaPgPDIs83jEnLE+QKU=; 7:cSJ0Z59XY2J6viYyIhh+YbJdl5y+jFMhR7gx9z7CFIVelFdqng6OCQw+0tsqOgvYGjoO7rozZTzJYwKtvT3KFSA6pue4G8JoTVuzOS3mm/NKS/s2YcezqRatIlt1H0ub+6Nr55XWdfreYPrgdWGQyXP2k7Q/3I80/kHqqTuz1qUVqAO9e6m8t22siuMJIVfSyp3LbsGXIFSHoVWBN9wKobp/JT45Ui3gr2QbiBm+ZpmZnDU4Qz3G6XIkrHHnKiIg SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2017 11:47:03.1600 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 173c9e8b-13d6-421e-911f-08d537e812ff X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR03MB2359 Subject: [dpdk-dev] [PATCH 2/3] kni: add support for promisc mode set 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" Inform userspace app about promisc mode change Signed-off-by: Hemant Agrawal --- doc/guides/sample_app_ug/kernel_nic_interface.rst | 29 +++++++++++++++++--- .../linuxapp/eal/include/exec-env/rte_kni_common.h | 2 ++ lib/librte_eal/linuxapp/kni/kni_net.c | 17 ++++++++++++ lib/librte_kni/rte_kni.c | 31 +++++++++++++++++++++- lib/librte_kni/rte_kni.h | 3 +++ test/test/test_kni.c | 2 ++ 6 files changed, 80 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/doc/guides/sample_app_ug/kernel_nic_interface.rst b/doc/guides/sample_app_ug/kernel_nic_interface.rst index d9d8e4a..9cb8463 100644 --- a/doc/guides/sample_app_ug/kernel_nic_interface.rst +++ b/doc/guides/sample_app_ug/kernel_nic_interface.rst @@ -512,11 +512,11 @@ Callbacks for Kernel Requests To execute specific PMD operations in user space requested by some Linux* commands, callbacks must be implemented and filled in the struct rte_kni_ops structure. -Currently, setting a new MTU, change in mac address and configuring the network interface(up/ down) -are supported. +Currently, setting a new MTU, change in mac address, configuring promiscusous mode +and configuring the network interface(up/ down) are supported. Default implementation for following is available in rte_kni library. Application may choose to not implement follwoing callbacks: - ``config_mac_address`` + ``config_mac_address`` and ``config_promiscusity`` .. code-block:: c @@ -525,6 +525,7 @@ may choose to not implement follwoing callbacks: .change_mtu = kni_change_mtu, .config_network_if = kni_config_network_interface, .config_mac_address = kni_config_mac_address, + .config_promiscusity = kni_config_promiscusity, }; /* Callback for request of changing MTU */ @@ -626,3 +627,25 @@ may choose to not implement follwoing callbacks: return ret; } + + /* Callback for request of configuring promiscuous mode */ + + static int + kni_config_promiscusity(uint16_t port_id, uint8_t to_on) + { + if (port_id >= rte_eth_dev_count() || port_id >= RTE_MAX_ETHPORTS) { + RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id); + return -EINVAL; + } + + RTE_LOG(INFO, KNI, "Configure promiscuous mode of %d to %d\n", + port_id, to_on); + + if (to_on) + rte_eth_promiscuous_enable(port_id); + else + rte_eth_promiscuous_disable(port_id); + + return 0; + } + diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h index 1a760de..f2ef48e 100644 --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h @@ -80,6 +80,7 @@ enum rte_kni_req_id { RTE_KNI_REQ_UNKNOWN = 0, RTE_KNI_REQ_CHANGE_MTU, RTE_KNI_REQ_CFG_NETWORK_IF, + RTE_KNI_REQ_CHANGE_PROMISC, RTE_KNI_REQ_CHANGE_MAC_ADDR, RTE_KNI_REQ_MAX, }; @@ -94,6 +95,7 @@ struct rte_kni_request { uint32_t new_mtu; /**< New MTU */ uint8_t if_up; /**< 1: interface up, 0: interface down */ uint8_t mac_addr[6]; /**< MAC address for interface */ + uint8_t promiscusity;/**< 1: promisc mode enable, 0: disable */ }; int32_t result; /**< Result for processing request */ } __attribute__((__packed__)); diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c index 3e02ea1..e261c58 100644 --- a/lib/librte_eal/linuxapp/kni/kni_net.c +++ b/lib/librte_eal/linuxapp/kni/kni_net.c @@ -603,6 +603,22 @@ kni_net_change_mtu(struct net_device *dev, int new_mtu) return (ret == 0) ? req.result : ret; } +static void +kni_net_set_promiscusity(struct net_device *netdev, int flags) +{ + struct rte_kni_request req; + struct kni_dev *kni = netdev_priv(netdev); + + memset(&req, 0, sizeof(req)); + req.req_id = RTE_KNI_REQ_CHANGE_PROMISC; + + if (netdev->flags & IFF_PROMISC) + req.promiscusity = 1; + else + req.promiscusity = 0; + kni_net_process_request(kni, &req); +} + /* * Checks if the user space application provided the resp message */ @@ -712,6 +728,7 @@ static const struct net_device_ops kni_net_netdev_ops = { .ndo_open = kni_net_open, .ndo_stop = kni_net_release, .ndo_set_config = kni_net_config, + .ndo_change_rx_flags = kni_net_set_promiscusity, .ndo_start_xmit = kni_net_tx, .ndo_change_mtu = kni_net_change_mtu, .ndo_do_ioctl = kni_net_ioctl, diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index 04db3df..e8cd297 100644 --- a/lib/librte_kni/rte_kni.c +++ b/lib/librte_kni/rte_kni.c @@ -552,6 +552,26 @@ kni_config_mac_address(uint16_t port_id, uint8_t mac_addr[]) return ret; } +/* default callback for request of configuring promiscuous mode */ +static int +kni_config_promiscusity(uint16_t port_id, uint8_t to_on) +{ + if (port_id >= rte_eth_dev_count() || port_id >= RTE_MAX_ETHPORTS) { + RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id); + return -EINVAL; + } + + RTE_LOG(INFO, KNI, "Configure promiscuous mode of %d to %d\n", + port_id, to_on); + + if (to_on) + rte_eth_promiscuous_enable(port_id); + else + rte_eth_promiscuous_disable(port_id); + + return 0; +} + int rte_kni_handle_request(struct rte_kni *kni) { @@ -591,6 +611,14 @@ rte_kni_handle_request(struct rte_kni *kni) req->result = kni_config_mac_address( kni->ops.port_id, req->mac_addr); break; + case RTE_KNI_REQ_CHANGE_PROMISC: /* Change PROMISCUOUS MODE */ + if (kni->ops.config_promiscusity) + req->result = kni->ops.config_promiscusity( + kni->ops.port_id, req->promiscusity); + else + req->result = kni_config_promiscusity( + kni->ops.port_id, req->promiscusity); + break; default: RTE_LOG(ERR, KNI, "Unknown request id %u\n", req->req_id); req->result = -EINVAL; @@ -741,7 +769,8 @@ kni_check_request_register(struct rte_kni_ops *ops) if ((NULL == ops->change_mtu) && (NULL == ops->config_network_if) - && (NULL == ops->config_mac_address)) + && (NULL == ops->config_mac_address) + && (NULL == ops->config_promiscusity)) return KNI_REQ_NO_REGISTER; return KNI_REQ_REGISTERED; diff --git a/lib/librte_kni/rte_kni.h b/lib/librte_kni/rte_kni.h index a53329b..bc5ead7 100644 --- a/lib/librte_kni/rte_kni.h +++ b/lib/librte_kni/rte_kni.h @@ -72,6 +72,9 @@ struct rte_kni_ops { /* Pointer to function of configuring network interface */ int (*config_network_if)(uint16_t port_id, uint8_t if_up); + /* Pointer to function of configuring promiscuous mode */ + int (*config_promiscusity)(uint16_t port_id, uint8_t to_on); + /* Pointer to function of configuring mac address */ int (*config_mac_address)(uint16_t port_id, uint8_t mac_addr[]); }; diff --git a/test/test/test_kni.c b/test/test/test_kni.c index 06448c9..56a7f3b 100644 --- a/test/test/test_kni.c +++ b/test/test/test_kni.c @@ -104,6 +104,7 @@ static struct rte_kni_ops kni_ops = { .change_mtu = NULL, .config_network_if = NULL, .config_mac_address = NULL, + .config_promiscusity = NULL, }; static unsigned lcore_master, lcore_ingress, lcore_egress; @@ -262,6 +263,7 @@ test_kni_register_handler_mp(void) .change_mtu = kni_change_mtu, .config_network_if = NULL, .config_mac_address = NULL, + .config_promiscusity = NULL, }; if (!kni) {