From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0064.outbound.protection.outlook.com [104.47.38.64]) by dpdk.org (Postfix) with ESMTP id 231901B025 for ; Thu, 18 Jan 2018 07:14:12 +0100 (CET) Received: from BN6PR03CA0064.namprd03.prod.outlook.com (10.173.137.26) by DM5PR03MB2700.namprd03.prod.outlook.com (10.168.197.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Thu, 18 Jan 2018 06:14:11 +0000 Received: from BL2FFO11FD030.protection.gbl (2a01:111:f400:7c09::104) by BN6PR03CA0064.outlook.office365.com (2603:10b6:404:4c::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.407.7 via Frontend Transport; Thu, 18 Jan 2018 06:14:11 +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 BL2FFO11FD030.mail.protection.outlook.com (10.173.161.40) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.345.12 via Frontend Transport; Thu, 18 Jan 2018 06:14:10 +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 w0I6E6hA024428; Wed, 17 Jan 2018 23:14:09 -0700 From: Hemant Agrawal To: CC: Date: Thu, 18 Jan 2018 11:42:59 +0530 Message-ID: <1516255980-25092-2-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516255980-25092-1-git-send-email-hemant.agrawal@nxp.com> References: <1514284608-9263-1-git-send-email-hemant.agrawal@nxp.com> <1516255980-25092-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131607296508466687; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(7966004)(396003)(39860400002)(39380400002)(376002)(346002)(2980300002)(1110001)(1109001)(339900001)(3190300001)(199004)(189003)(53936002)(48376002)(97736004)(4326008)(50226002)(8676002)(8936002)(85426001)(50466002)(36756003)(81166006)(81156014)(86362001)(316002)(508600001)(51416003)(26005)(2950100002)(6916009)(6666003)(2906002)(68736007)(16586007)(2351001)(356003)(106466001)(305945005)(47776003)(76176011)(104016004)(105606002)(5660300001)(59450400001)(77096007); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR03MB2700; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD030; 1:Sxrc6A/MajNrW1ggpllnaFUO1tvgKwsLtVEEXcscawfnFJe5d6dw15LycFkwAmNYYxsBFdkMzPZ+43sMbwg0BynsdN7S2V92uMECXazphiQC6XvDDEgcj/iP3XJPRxZL MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8c141373-cb81-4252-95ff-08d55e3ab0b3 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(5600026)(4604075)(2017052603307); SRVR:DM5PR03MB2700; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2700; 3:NFwhzHXovxRQVRCHr2acGtf1KdMRq1aLXNyybg0iuNkWqQ+Se0ZlIl4EfaSzyqd07RnHVy00quykTidw0XL0V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gmNhaHIXIGjwAdFA/jIdwmAG1ooEMwvCJ2NMAK3mBMPno4n1+yxl/3s15576ldZDlJ7Unp/VNVlhoYELnMqMu0pBAj3VmHmHN0zqzvHU+knawcvbNDIPUBcmCi/lxnDy2fqQHURN7Xu9STLdVqo196y1WMhELG5K3S4QriotImi5 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)(10201501046)(3231023)(944501161)(3002001)(93006095)(93001095)(6055026)(6096035)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(20161123561025)(20161123565025)(20161123556025)(20161123559100)(20161123563025)(201708071742011); SRVR:DM5PR03MB2700; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:DM5PR03MB2700; X-Forefront-PRVS: 05568D1FF7 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR03MB2700; 23:kCVbFo/6LBShE5dOGH8LzmAVshNq+FjH+9itDwcrq?= =?us-ascii?Q?IrceuDgQ6e1MFSdniumgr2+UhzRxo6njgXwjmZodNdbrWtz3WATC84wO2O4h?= =?us-ascii?Q?asEroQVzhnOVcBDjAzBEGM57fCU3cCBm4p6eYCnEIlOwU5C8/ZjXKFA5N4hH?= =?us-ascii?Q?4GvxhSiL2Sk2KVTgyCaXjmHQOqqM51YDW4XAdiFf4ohy+2GQvHJ5xlh5y426?= =?us-ascii?Q?BNmEfqjEHu45nvs+ahhRux4cjXinqWWWeVTOkox6mCQ5MJKpFlEkcPa6TyxT?= =?us-ascii?Q?WaRQAZvRyzyxrTFdF9QdfCPaRL5rKmL5nzN29GkkN9R6gwzIRhn8OSZFg0Oz?= =?us-ascii?Q?AmKPsTCGK1LwmMNd26sOrAltt6gqAVgY9gesVLqvKU9+jCGaZZU6OIHMf4ji?= =?us-ascii?Q?KHHOrfi0TtsP6NaJepPLSD2QnRCF9d1oyBrtNm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MPwgvbjCfTtMVtdarQi4Y/bgVwzQU1da24PpMjn3DuP5fzJRyXz6G85Z8qwa4+YK6ljzjpgeeOQenEcshcaA1ZatrIAALXtnAd6qzD7aYYGrAHd6f00iuJh235I83vpEP+vTs/VRYbOhwThYZO9TZikbl60vfnRAnDsNQ67N8V8C4g/xgTFHh7IkI5RJ/gEAzs=; 5:ogB0jo1y7GXuZAcfvSsW+hRvlPpUXNVALQxAHx2cp1SgeCIt7ysccuHjdhV2RQxSogNLOh+bSdyEmccjc6hFM5qwdipKFe8ToB/HJliEPQ/7c2zj+u4TSdKKGErvxxejcD4nKctY9WhIKITsvN0XnRVamRDIjA718zMtNJ9UY+w=; 24:k+W2VAq9dO/LJ0ACJOhGkHV/e9EVrGyOSNKFtn3pNOvmmAhkps9Z/3bVbQzqc6o4rRELvx/tJRlDCRumzl8hJCYDlU8AISUC17WDzn4RdUo=; 7:FSbhVTweoQsfukL5daKQb5b6QZBw26etr3EAzmjvbVcs+K00y24+9Eir6CT6I6pIvaC6HIeC8ad04u8Gtc4B5p/gib4PFgDiQ8U4LSKVhHmeOlp+UeKRsxT+07cUBxPf0hXsw7ze9HTePb0uCAv2ojMWFzwilQ1WXTTuyw4Dcwz04f/93CCNRosx3HqvRVPNGkbOdzmiW/NrLQLz+qtTrYmlkwaXCSmfcmbYlyhJ/etEusQYHoAoTtuFjyV5wpfD SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2018 06:14:10.6906 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c141373-cb81-4252-95ff-08d55e3ab0b3 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: DM5PR03MB2700 Subject: [dpdk-dev] [PATCH v3 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: Thu, 18 Jan 2018 06:14:13 -0000 Inform userspace app about promisc mode change Signed-off-by: Hemant Agrawal --- v3: fix checkpatch warning and compilation err 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 d7989bf..fdd061e 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 62b4a05..b186417 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 @@ -29,6 +29,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, }; @@ -42,6 +43,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 3e35008..9f9b798 100644 --- a/lib/librte_eal/linuxapp/kni/kni_net.c +++ b/lib/librte_eal/linuxapp/kni/kni_net.c @@ -584,6 +584,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 */ @@ -693,6 +709,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 a140dfc..c089a49 100644 --- a/lib/librte_kni/rte_kni.c +++ b/lib/librte_kni/rte_kni.c @@ -525,6 +525,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) { @@ -564,6 +584,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 != UINT16_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; @@ -714,7 +742,8 @@ kni_check_request_register(struct rte_kni_ops *ops) if ((ops->change_mtu == NULL) && (ops->config_network_if == NULL) - && (ops->config_mac_address == NULL)) + && (ops->config_mac_address == NULL) + && (ops->config_promiscusity == NULL)) 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 370b02a..711c2a9 100644 --- a/lib/librte_kni/rte_kni.h +++ b/lib/librte_kni/rte_kni.h @@ -45,6 +45,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 4513de1..9917e8a 100644 --- a/test/test/test_kni.c +++ b/test/test/test_kni.c @@ -75,6 +75,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; @@ -233,6 +234,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