From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0074.outbound.protection.outlook.com [104.47.37.74]) by dpdk.org (Postfix) with ESMTP id B13F71B243 for ; Tue, 26 Dec 2017 11:37:55 +0100 (CET) Received: from MWHPR03CA0026.namprd03.prod.outlook.com (10.174.173.143) by DM5PR03MB2699.namprd03.prod.outlook.com (10.168.197.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.323.15; Tue, 26 Dec 2017 10:37:54 +0000 Received: from BN1AFFO11FD019.protection.gbl (2a01:111:f400:7c10::146) by MWHPR03CA0026.outlook.office365.com (2603:10b6:301:3b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.366.8 via Frontend Transport; Tue, 26 Dec 2017 10:37:53 +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 BN1AFFO11FD019.mail.protection.outlook.com (10.58.52.79) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.345.12 via Frontend Transport; Tue, 26 Dec 2017 10:37:34 +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 vBQAbmE0009888; Tue, 26 Dec 2017 03:37:51 -0700 From: Hemant Agrawal To: CC: Date: Tue, 26 Dec 2017 16:06:47 +0530 Message-ID: <1514284608-9263-2-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514284608-9263-1-git-send-email-hemant.agrawal@nxp.com> References: <1512042367-6361-1-git-send-email-hemant.agrawal@nxp.com> <1514284608-9263-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131587582548182740; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(336005)(376002)(396003)(39860400002)(346002)(39380400002)(2980300002)(1109001)(1110001)(339900001)(3190300001)(189003)(199004)(68736007)(85426001)(51416003)(4326008)(498600001)(76176011)(5660300001)(2351001)(106466001)(2906002)(305945005)(59450400001)(8676002)(8936002)(50226002)(81156014)(81166006)(6916009)(6666003)(86362001)(53936002)(97736004)(36756003)(50466002)(104016004)(77096006)(105606002)(356003)(47776003)(2950100002)(48376002)(316002)(16586007); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR03MB2699; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD019; 1:WvMpxNLdngyGqz26x8wmWIYaXGizpTOJoaNPHUrTRaiAdW8qcb3opaHE74nHvdezwayCkygJzPd6hCo5LdEYdaUg3WnHc7ToZ9vgdU0oHahv3qFkUcKthPUsB265pY2d MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f234bbf2-8f3b-4693-06d4-08d54c4cad1a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4628075)(201703131517081)(2017052603307); SRVR:DM5PR03MB2699; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2699; 3:8BJtrvxBrdFA5mf3azDpcAf9qX/Lu5GMSIhv/3TIMhUiT46nxlwGsIfvlQkSBTCbdCH56J5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4Eyon9hWZlo9nb2e47gOtI/6SfdEiH7JTJ5h2vgXuXkjtiMckU4gEae/N9zIJRP9+4Rjg4x59kxegg6bAA+T7jFUrm2hV+fQRiHHCCC4verXlWG8FwtHv54fCfXAAx7AIn1sIaASlGK0IFcBYCOeqDrJ9msD60Ao+BalNx97XAHvHZy6MzQGz6W/SCRRgr X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(3231023)(944510075)(944921075)(946801075)(946901075)(6055026)(6096035)(20161123556025)(201703131430075)(201703131433075)(201703131448075)(201703161259150)(201703151042153)(20161123559100)(20161123561025)(20161123563025)(20161123565025)(201708071742011); SRVR:DM5PR03MB2699; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:DM5PR03MB2699; X-Forefront-PRVS: 053315510E X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR03MB2699; 23:LF9RLDaaDW+wq+2GYXh+msdp5NOmicTiVqAo2dY2G?= =?us-ascii?Q?ZvQgs+61UDj14dztE7FLNfIM7+METvUNE6cTR/eTRJzYzAeo7lZGZlkJ2TPi?= =?us-ascii?Q?Cw+767JNSQrwG5fScogHbuwh8BkAbK6rF7Dk2flXQuq+4SxT6Jj3QcD0WqeX?= =?us-ascii?Q?H+33weA+XxXWAhsazIWGMs9jXHdjzU6k4BAU6C2spqIjtmELEBAb/gpHFXkv?= =?us-ascii?Q?gPKYdO3e+Id3rH+7sHbKw9O8JWfiJ1Zs16bJQtyK+FNEbyXTxnWZdwrxOgWj?= =?us-ascii?Q?EjTG2Nl37ac9sEOZGuNRH7b/TCseSJiIeo0jUAwnlJQ+FVQJxdTLhp+ZOfJg?= =?us-ascii?Q?kB3wENuCAmC1ggtqNbixOGZqWwQMifmA4LsGiSz9uAOtUobP/kDbOk3Avfs4?= =?us-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g6xcEIAan2ukKHbX/XRxpBrbFSyIGXNxRSi3ri6RuMqti9xPnoX4THSLGb5RGQYOxVJiaTCTovkBDyOzFMAOOSW/EU3t0qvXklfn+CUv8pWwqAga78evhe5xV8gXW9t7HmQR0GdV9Dwx6D5Qh/It6S6B302Owzsyv/OmryDGV7jHfNSsY7SvV/PZfCQyjrIxoGRr0CFk=; 5:lbVTcg8a8Fu33EZhPzt2ankXvTubAwU5X3k10/rzORU3xjGKtzQ6JaOFAdT+Z3LnXy2H03yNaXYEPVJN/OjiK29G9pyJb5sLBtaRAj6u2pBM7yBSCaLUCC7hCAcnfve64MLrYRZtHJtRKmgkKTCcPfWnklMGuSpqDj7mSAlBY4I=; 24:QMJ+49CIzXg4AKVmCaxE/ccvPCMdJvOQUa9bipSs+X6W5+6j3QcjlRKIF7xV5L2neToswaGBWNYJtHaqOOAPALalEMVjeSleYxjPwORnnCs=; 7:phInhy4drfbp2jVwf+9n4t0s9Qui1vLpPZGMhBjZFopb+8lyFilmEDWaVzj1AAw/BM3I9BhKRNfPp54TUdRrsebPtRrBJIILL4Ko4k76KIYxrK6I6TKzxR7DP5r3ZlQdMDBpOzsNvwmapxiqUJ2rBLlXf70qMWTldriqvCSmPsGQz91s8YzMfRIKDDdvYr3VHovVNoB3GJSSnEweBnltvMhGwd+8rcXGfFGqk7u4y6woimT+PkpI52i4k5C7qZEO SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Dec 2017 10:37:34.6466 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f234bbf2-8f3b-4693-06d4-08d54c4cad1a 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: DM5PR03MB2699 Subject: [dpdk-dev] [PATCH v2 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: , X-List-Received-Date: Tue, 26 Dec 2017 10:37:56 -0000 Inform userspace app about promisc mode change Signed-off-by: Hemant Agrawal --- v2: * fix ABI breakage * check for ops.port_id for vdev case doc/guides/sample_app_ug/kernel_nic_interface.rst | 15 ++++++++--- .../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, 66 insertions(+), 4 deletions(-) diff --git a/doc/guides/sample_app_ug/kernel_nic_interface.rst b/doc/guides/sample_app_ug/kernel_nic_interface.rst index 2c143da..4dd1f82 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 */ @@ -611,3 +612,11 @@ may choose to not implement follwoing callbacks: { ..... } + + /* Callback for request of configuring promiscuous mode */ + + static int + kni_config_promiscusity(uint16_t port_id, uint8_t to_on) + { + ..... + } 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..b519db5 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 @@ -81,6 +81,7 @@ enum rte_kni_req_id { RTE_KNI_REQ_CHANGE_MTU, RTE_KNI_REQ_CFG_NETWORK_IF, RTE_KNI_REQ_CHANGE_MAC_ADDR, + RTE_KNI_REQ_CHANGE_PROMISC, 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 a5ee210..bed3f20 100644 --- a/lib/librte_kni/rte_kni.c +++ b/lib/librte_kni/rte_kni.c @@ -554,6 +554,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) { @@ -593,6 +613,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 if (kni->ops.port_id != UNIT16_MAX) + 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; @@ -743,7 +771,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 9bdc9f3..4530bdd 100644 --- a/lib/librte_kni/rte_kni.h +++ b/lib/librte_kni/rte_kni.h @@ -74,6 +74,9 @@ struct rte_kni_ops { /* Pointer to function of configuring mac address */ int (*config_mac_address)(uint16_t port_id, uint8_t mac_addr[]); + + /* Pointer to function of configuring promiscuous mode */ + int (*config_promiscusity)(uint16_t port_id, uint8_t to_on); }; /** 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) { -- 2.7.4