From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10074.outbound.protection.outlook.com [40.107.1.74]) by dpdk.org (Postfix) with ESMTP id ED866A84C for ; Tue, 17 Apr 2018 14:53:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coriant.onmicrosoft.com; s=selector1-coriant-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=+HsIGF3Yxy14UnBlcFTw8OQzdxEciMd+r03O7eMPGGM=; b=GWcDuo9ZPQej4yNQ0ac6tK0+R/NyKGuy8ENpEZtD84DpOWrMEtnMyR5DWtgJRZx7Sovjnx/1pdMJGv5V4tXcM0jt5TUIw0FuZftk+/4+hjNC3SzhfD4HNPPLYJgv6nm31go6eEf3yHACusXT8ASHdb/g/VGEcakHaZISIqcbPtU= Received: from HE1PR0401CA0069.eurprd04.prod.outlook.com (2603:10a6:3:19::37) by AM0PR04MB4289.eurprd04.prod.outlook.com (2603:10a6:208:67::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.675.11; Tue, 17 Apr 2018 12:53:29 +0000 Received: from AM5EUR02FT062.eop-EUR02.prod.protection.outlook.com (2a01:111:f400:7e1e::206) by HE1PR0401CA0069.outlook.office365.com (2603:10a6:3:19::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.696.12 via Frontend Transport; Tue, 17 Apr 2018 12:53:29 +0000 Received-SPF: Pass (protection.outlook.com: domain of coriant.com designates 204.154.131.209 as permitted sender) receiver=protection.outlook.com; client-ip=204.154.131.209; helo=usnapvlsmtp01.coriant.com; Received: from usnapvlsmtp01.coriant.com (204.154.131.209) by AM5EUR02FT062.mail.protection.outlook.com (10.152.9.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.675.14 via Frontend Transport; Tue, 17 Apr 2018 12:53:28 +0000 Received: from fies1uas61.tellabs.fi (unknown [172.23.229.177]) by usnapvlsmtp01.coriant.com (Postfix) with ESMTP id 171E24024C; Tue, 17 Apr 2018 07:53:26 -0500 (CDT) From: Juhamatti Kuusisaari To: CC: , Juhamatti Kuusisaari Date: Tue, 17 Apr 2018 15:53:09 +0300 Message-ID: <1523969590-40071-1-git-send-email-juhamatti.kuusisaari@coriant.com> X-Mailer: git-send-email 2.8.1 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:204.154.131.209; IPV:CAL; SCL:-1; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39380400002)(396003)(346002)(39860400002)(376002)(2980300002)(438002)(199004)(189003)(305945005)(86362001)(6266002)(104016004)(53936002)(26826003)(478600001)(69596002)(72206003)(486006)(59450400001)(26005)(356003)(48376002)(51416003)(50226002)(50466002)(6346003)(77096007)(575784001)(97736004)(106466001)(426003)(47776003)(6666003)(81156014)(6916009)(107886003)(36756003)(8676002)(2906002)(68736007)(4326008)(81166006)(316002)(8936002)(106002)(53416004)(2616005)(476003)(126002)(5660300001)(16586007)(336012)(54906003)(2351001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB4289; H:usnapvlsmtp01.coriant.com; FPR:; SPF:Pass; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; AM5EUR02FT062; 1:j3qCdReUQ2dN5rZlcdSq59akAiD2rZQy+QSBkwfmm6GYP7P4GOdAO6q/339RhBJCFUqs8GSIUc0yGd915BI/1L8wrUDteaPTPPaeIXbi3lW1xtm+iAcZCWe6bIjOBZte MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4608076)(2017052603328)(7153060); SRVR:AM0PR04MB4289; X-Microsoft-Exchange-Diagnostics: 1; AM0PR04MB4289; 3:m5m6oIoANIM1D4TpFPQiPhctxr+3FjafRPkeH3VwA0exD3F1D0zsLgoZf3odpcNr635YTlCBEx/EVGGVxbRx4pUjBW7kb6n2S+brU1YvMCb0z817VzgJteZ/bhG7fLpnQqI43RgJWcErY1lmS7K1nlCsANoyWHKbPttcWdLS6vWg0YtQvBl98diSax5pSawAS1cGSiMR46iFaqkPsKhJ4a1HRfI2w8nHDarMxDuhPpAVa9orXWkDjoLNxg5erhetaECBbRZevvjUVlQIw5GZViMme3OcXrdlLe2TX/cI9of2iPlwsMCAaIXWHalrJnI3RGyKip3jq1wth9LKQK0weTOJUUb97TuQYb5BOp7vWXs=; 25:6/9nr53g6DTr29WZ2m2K37GolANqvU5CeYktClqto3Smn7x68Y4ZA5uCY5cQhprv0lihubAPv0Ji8xV+kbpKQKh0HAz/t1whoVjYdmPqhC3q9Imt3Bu1fs2NICHB1tUTS6RtxwmFnOafDR5W2NqcKMy9aCpsc1Aj0Y8glH6tFLx8Jy8IX00NnEzS+a1vNBfVHcGGgMjzg76IDKZAyEb5SywM7KnJl20IXcaMZScwEcYZAx0Cnqrv78S370PixI+sVKhXHFExSQdHZuA8eSGGKD2+54xYeNmgUgU0VDLsDqdsMXyrQsxhnmjjavHk50dkbt96bZYvI+g9K4uYoEdKMw== X-MS-TrafficTypeDiagnostic: AM0PR04MB4289: X-Microsoft-Exchange-Diagnostics: 1; AM0PR04MB4289; 31:6pO3DH7x1rPJ5bUmfm/emwWTKEa94F6ngE0/PuuQ+6w5L9GQz2KAU8TV47DVpuH3t9v5vmHT+e9MAXhxx9/JhcwjZNWVbsTl4bqmLMFfFCoCttsiosSDWtIYJS+0WzSbYyoJmblxGd2ibP+nWM0Pywwy3joT0+735CliQ1pe4LEKxUCwe+PsVexWWP9bK2rTMMvZS/WIhbO4og63IGXT1sJCu3DoCWtRQJAN8Se3Kmg=; 20:h1EK5mibWx3vdiu/NsO6h49ct+yNgmUioiNPu4zWiwaVNUfz+BMbkUVoUgKIz6+kK2ki90y7LoquZoI0uvjp7iVjKKYI+CmWNcxl/HH62/vOUa1grh/fKHdev/UDFOwTmyhzgrrD5d30a5Waeml7ZCVro+ibBSvLlEyOjWMS1TXcM6G959m0Q4Fv/HEAOaje90BMrVEYSQKdDc9vLj9Rph1+mSEy+uAO4Aysr67vmSpxE96GKzeaNdmF5nNhRXfOftPaerh/rt3L4eflUnJaQ5wcCL5p+gtKOIgDomiGtPx9xPo76+PEdVuN/A7KswVJsbbjP0k6Cucjyv/bRnY3He9MKWiH7jVOxS+95g5pUCaYZWeTo2SaM/tpHj3KlSMd7/TdYTwDGEJL4sIB7fiM8RfIp5K+luBovovruJbzXQnGtjWD73gDR2dZ8Inl3vrEdAtrDqLnNYpsQsG3YqI9LX1yO5JEd+kku1hgGS1eJgmZjbErj+feyuTRPOVMSjOsfVkkTaWBB3HSveOxV2bKK0TOSbrY9ne4O95bo6KNoPx3+JMaZOBBvrraZH9B53TjIbXtnfV+xfVsljf1Ocdt5Ye1K0sBP5UkfkQU0vYPJDk= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(51653755401839); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93004095)(3231232)(944501359)(52105095)(6055026)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:AM0PR04MB4289; BCL:0; PCL:0; RULEID:; SRVR:AM0PR04MB4289; X-Microsoft-Exchange-Diagnostics: 1; AM0PR04MB4289; 4:e9E5LBUjnjPhImdN+IzdVAV+ZkTWTk6NnXFwSmowUQQ/nqvl3NDqkWlVsPzC95t7EX52b01ZgT4miCt7uFS36n8u75IzdYdUaJwqSRzQ/m6bO2vY4aNtxCLeRZZkUZclpZ06Ju+gz0NhCjzsTX6MwRmCr4Eeb/4AVOlKF5b4cb7QyHvEj1S56sOQLr9Tve4dXN41Kq4/QbsjafAxIvTLBXTTX2sOm41X/YH9ZOGUNs8s5XkJMIxohMGDcadHf7W/VOj16Neiif5KWB75PRanIVxD0sh1udKLE5fcK2hOkvW7ivlJl6zEEmmn1Uvv6mv2 X-Forefront-PRVS: 0645BEB7AA X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM0PR04MB4289; 23:FTa5+L60EREijqksnOKTaP1fLI2ALL3ECp1iffwM/?= =?us-ascii?Q?Hm9qDrTacn1eZtPluFWD7fZw2DwnS5N0LW+CFtJXHhfhfZ6+jafCQQbCuAUp?= =?us-ascii?Q?rAn/KeH5RGeU5dP77Bjwo5+SmBuwQB6kLzHGgeF5ROQhVsF3Q+3LW8Bp+ldo?= =?us-ascii?Q?6R6/1v654teSKQe1CIzdhXkHPsweyKUO+2PIJViA4OzG/hdAYBEmbSPpWioH?= =?us-ascii?Q?M31YHuy9iN9ndjUx0smPhLRejGY6ZqvNrEdmlenXz0Ds/1GO/PK+JVzhyYd3?= =?us-ascii?Q?thrQw4Cch7PA/H4GK25HprjWLviCNH6tL0SlEQJL3lbYo0gjE7vYo7jBmmON?= =?us-ascii?Q?8D953muYOaSqNvzkmATygwbdRTxwsROM15QFOwD26EujiXhB1+WR1ia0oPqF?= =?us-ascii?Q?F8oOXMtxYMCYeahxEeo69rElAF9mvUYmdSCjilLJ1H/CFF0FNAS8g03UwHL7?= =?us-ascii?Q?HahpEViI9FfqkIkct7AJH5F1Q8fXBujLjzS4TDXg7pReoo87AFyjby29hd5V?= =?us-ascii?Q?XgLBR7t9SQOx17tGi9amOyDrDnO9mAlhdd5IPxuct62VbmDAYOfgU7wx5coo?= =?us-ascii?Q?DuXCBIesA09nj4v8ZuDQOvQxzz1ZLraG625NTthyygnr8/sYmk5ZFt7xtee5?= =?us-ascii?Q?qxkuDF758szi3pxHL2uX2YNXH3A8Wjl2SK62gTi6XJR+BgfU1UqqQ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WasWdrL9HO1Olkm8ZynKhUSwx3Mks4AD0lxJKAdSc2m8t26fD2oKW+XyFsZsqUjOAOvQByF0GpQoJZVKILugRKpuYuv+wbd0iI0ps9pVJdzQWqYqGpkF888m/t0xPkdMEuNvCOXK/pALS20AWqnCwTS8AsHB6XceJrSrv561SD X-MS-Office365-Filtering-Correlation-Id: bd35efdd-f82b-4c97-f406-08d5a4623784 X-OriginatorOrg: coriant.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2018 12:53:28.5347 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd35efdd-f82b-4c97-f406-08d5a4623784 X-MS-Exchange-CrossTenant-Id: 76595477-907e-4695-988b-a6b39087332d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=76595477-907e-4695-988b-a6b39087332d; Ip=[204.154.131.209]; Helo=[usnapvlsmtp01.coriant.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4289 Subject: [dpdk-dev] [PATCH v2 1/2] net/pcap: physical interface MAC support 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, 17 Apr 2018 12:53:31 -0000 Support for PCAP MAC address using physical interface MAC. Support for getting proper link status, speed and duplex. Signed-off-by: Juhamatti Kuusisaari --- config/common_base | 1 + drivers/net/pcap/rte_eth_pcap.c | 52 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/config/common_base b/config/common_base index c2b0d91..9804585 100644 --- a/config/common_base +++ b/config/common_base @@ -410,6 +410,7 @@ CONFIG_RTE_LIBRTE_PMD_NULL=y # Compile software PMD backed by PCAP files # CONFIG_RTE_LIBRTE_PMD_PCAP=n +CONFIG_RTE_LIBRTE_PMD_PCAP_IF_MAC_SUPPORT=n # # Compile example software rings based PMD diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index c1571e1..d2aba1c 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -7,6 +7,13 @@ #include #include +#ifdef RTE_LIBRTE_PMD_PCAP_IF_MAC_SUPPORT +#include +#include +#include +#include +#include +#endif /* RTE_LIBRTE_PMD_PCAP_IF_MAC_SUPPORT */ #include @@ -67,6 +74,10 @@ struct pmd_internals { struct pcap_tx_queue tx_queue[RTE_PMD_PCAP_MAX_QUEUES]; int if_index; int single_iface; +#ifdef RTE_LIBRTE_PMD_PCAP_IF_MAC_SUPPORT + const char *if_name; + int if_fd; +#endif /* RTE_LIBRTE_PMD_PCAP_IF_MAC_SUPPORT */ }; struct pmd_devargs { @@ -602,6 +613,27 @@ static int eth_link_update(struct rte_eth_dev *dev __rte_unused, int wait_to_complete __rte_unused) { +#ifdef RTE_LIBRTE_PMD_PCAP_IF_MAC_SUPPORT + struct ifreq ifr; + struct ethtool_cmd cmd; + struct pmd_internals *internals = dev->data->dev_private; + + if (internals->if_name && (internals->if_fd != -1)) { + /* Get link status, speed and duplex from the underlying interface */ + strncpy(ifr.ifr_name, internals->if_name, sizeof(ifr.ifr_name)-1); + ifr.ifr_name[sizeof(ifr.ifr_name)-1] = 0; + if (!ioctl(internals->if_fd, SIOCGIFFLAGS, &ifr)) + dev->data->dev_link.link_status = (ifr.ifr_flags & IFF_UP) ? 1 : 0; + + cmd.cmd = ETHTOOL_GSET; + ifr.ifr_data = (void *)&cmd; + if (!ioctl(internals->if_fd, SIOCETHTOOL, &ifr)) { + dev->data->dev_link.link_speed = ethtool_cmd_speed(&cmd); + dev->data->dev_link.link_duplex = + cmd.duplex ? ETH_LINK_FULL_DUPLEX : ETH_LINK_HALF_DUPLEX; + } + } +#endif /* RTE_LIBRTE_PMD_PCAP_IF_MAC_SUPPORT */ return 0; } @@ -866,8 +898,26 @@ eth_from_pcaps_common(struct rte_vdev_device *vdev, if (pair == NULL) (*internals)->if_index = 0; - else + else { (*internals)->if_index = if_nametoindex(pair->value); +#ifdef RTE_LIBRTE_PMD_PCAP_IF_MAC_SUPPORT + /* Use real interface mac addr, save name and fd for eth_link_update() */ + (*internals)->if_name = strdup(pair->value); + (*internals)->if_fd = socket(AF_INET, SOCK_DGRAM, 0); + if ((*internals)->if_fd != -1) { + struct ifreq ifr; + strncpy(ifr.ifr_name, pair->value, sizeof(ifr.ifr_name)-1); + ifr.ifr_name[sizeof(ifr.ifr_name)-1] = 0; + if (!ioctl((*internals)->if_fd, SIOCGIFHWADDR, &ifr)) { + (*eth_dev)->data->mac_addrs = rte_zmalloc_socket(NULL, ETHER_ADDR_LEN, 0, vdev->device.numa_node); + rte_memcpy((*eth_dev)->data->mac_addrs, ifr.ifr_addr.sa_data, ETHER_ADDR_LEN); + } + } +#endif /* RTE_LIBRTE_PMD_PCAP_IF_MAC_SUPPORT */ + } +#ifdef RTE_LIBRTE_PMD_PCAP_IF_MAC_SUPPORT + eth_link_update((*eth_dev), 0); +#endif /* RTE_LIBRTE_PMD_PCAP_IF_MAC_SUPPORT */ return 0; } -- 2.8.1