From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7A6F8A034C; Sun, 19 Jun 2022 11:31:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 660CF410EC; Sun, 19 Jun 2022 11:31:30 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20117.outbound.protection.outlook.com [40.107.2.117]) by mails.dpdk.org (Postfix) with ESMTP id 85E7F400EF for ; Sun, 19 Jun 2022 11:31:29 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X0yH55wvJRbuhFCq1I6FY4fDMDw5iABju1naCWwtul5B/szzHpoP7dHLVPIfDyrqRqzr81MlC/FxFRP4BCY4s1Tygt443zijXp3cmTqtJ/GLrMe13V1+Obmnn1JP3BxSfR1frCwj0TOdiiR6xwsIYoA254IOr1s1GZBIPnqZuugjUZvDoKwKXBKsCYzRN66qp+Pn0/OeX4I3YDXaAqZoPKZE3xSZQgkfTd2GdnycWQdqmIGoh5H48Kk25ZN+zCG5UsXNPA5FblECjGbaga3x0gwKcXZ9dgC4pz/SnzfQ/Ia5Z+weLRvxxh5cCr6wtHGgGTsEXI4JKvwOPcKw7yRe5w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W44yEpJL/QTtjVQBmqH1lVDlQyf5GgBYbFIZYAvmmno=; b=n699Nm32h7U33bsQQipFAdEzb0DPGQgHxuOp53NgSmgbBM+Yd3pvw26eQkCMiLywLsvW2/lnEe/i5JZwxyuYUgTCMCSj+pfcsPwWGgxfLDzfxzrzfyvBbaDBJovobAurnEpwVSze7pv2C5FiHINS+hn3llmJSXzhYISqgcbMYkkkJBTzJUwhGGsqJ9wzc9m6aSxTJBdaYk1gnzXqR/buw/SLGESK80JqjHQC0LyKlJF2MkkWkrT4UmAm+vrDuovMJNmpTX0Tz1BELwDK8en16HDesLu4nQ98g81vWFNO469kTcOyDJSqYv8JlML789MUhyWF/dyvD5sd1YTI49h4kg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cgstowernetworks.com; dmarc=pass action=none header.from=cgstowernetworks.com; dkim=pass header.d=cgstowernetworks.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cgstowernetworks.onmicrosoft.com; s=selector2-cgstowernetworks-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W44yEpJL/QTtjVQBmqH1lVDlQyf5GgBYbFIZYAvmmno=; b=fzjxzQ4GulgktruZKpefc7ByDzaorEGTomGV7dKvXrhGn8hE/RPYBRb3IsX9xztreaS2jUx0eRauepiRzmaSeuTejz1+160wmQ1Xy7MI7eTqVyDVp65OKfkvn+r77Qj+7ijSW+0C4TTJM3BiGPcuhoU9ZHPJfNQExlHbmJnnenc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=cgstowernetworks.com; Received: from AM0PR09MB3972.eurprd09.prod.outlook.com (2603:10a6:208:195::21) by PAXPR09MB5056.eurprd09.prod.outlook.com (2603:10a6:102:15e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.14; Sun, 19 Jun 2022 09:31:28 +0000 Received: from AM0PR09MB3972.eurprd09.prod.outlook.com ([fe80::d0d6:ba99:48ac:5e72]) by AM0PR09MB3972.eurprd09.prod.outlook.com ([fe80::d0d6:ba99:48ac:5e72%8]) with mapi id 15.20.5353.020; Sun, 19 Jun 2022 09:31:28 +0000 From: Ido Goshen To: ferruh.yigit@xilinx.com, stephen@networkplumber.org Cc: dev@dpdk.org, Ido Goshen Subject: [PATCH v7 1/3] pcap: support MTU set for linux interfaces Date: Sun, 19 Jun 2022 12:30:32 +0300 Message-Id: <20220619093034.26891-2-ido@cgstowernetworks.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220619093034.26891-1-ido@cgstowernetworks.com> References: <20220317174347.110909-1-ido@cgstowernetworks.com> <20220619093034.26891-1-ido@cgstowernetworks.com> Content-Type: text/plain X-ClientProxiedBy: VI1PR0901CA0095.eurprd09.prod.outlook.com (2603:10a6:800:7e::21) To AM0PR09MB3972.eurprd09.prod.outlook.com (2603:10a6:208:195::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 71a1a30a-5577-431f-5d6c-08da51d67cbf X-MS-TrafficTypeDiagnostic: PAXPR09MB5056:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XJTmylOl+RakloVpoMTxW58nUh7Ztz9lOG2l8HrX0JdQuCKvwiaq2n8AD561v1b2Yni7pldfq1Lu7aeIMHuqV/eyzHgMx2RY8xWXNW97ipNaLpUajSwLDuElr6US5G+UNf3ks+EwWxQcDpCRz41c/ATMhrKS+iT63k3po26qLgeYn9q0STFa06oM489rMkHBCMCAQUblIAjilYVn0/oF2kNB77aCyNecOD/B8A/nRwJJ1WuQZfIF9Le/VfPpajYJMoQTHX/pQ7MYFlaaDxl3M7tlOs5hStdC2PjSPyklr7RSOm3GM6oKvnEdHy0vKiAe+730P2efM4F9STpDDG1wX5eYj78n9eXnzylaXCT5qrQ38f8Cccp/ku2FWu6sUgw0zKR/WSE1UH1q2fvvtxwpV3wO+3YwueGPFdVMlkra9xX2Kipx1LaGTHhJQaZii2cmYrZCRB4MfLTytGScLVBoHh3AjBkl+pFLX81k8G1DsZzPizhu64f8qkmtNsqYMiWL3hNjfUuCykhO6yiC5bzv63xevDl5JwNqC+DXyJL5sMrGmm6wDhKk4Q6eWonVF9MqBP7TKeGaGF09Y9issS+gqe4OGReXLtqko0x+nF6+DZJf8/pp6Rg9THRP7DOx+LJWvBCcPTA1A3+Vh9d/Pv2Egx8NYxoOYA3f0GvWEE2iAuzXkkOhx98jeAm/oB4fHyTLXGJI5e2dMmkB2/aMkmInww== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR09MB3972.eurprd09.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(346002)(396003)(39830400003)(366004)(136003)(26005)(107886003)(41300700001)(6512007)(38100700002)(83380400001)(86362001)(508600001)(2906002)(6506007)(8936002)(6486002)(66556008)(38350700002)(52116002)(186003)(6666004)(1076003)(36756003)(316002)(66946007)(66476007)(4326008)(2616005)(5660300002)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?aUcFoYOGym8P6iIurxID9/Pw2qIq6ZtbieoCwIEc6vrmiIMKYw/ibFM40eFC?= =?us-ascii?Q?x4lVesRrm4dFxrqPAPMeECui7e6lw/i7M4UfABQefB0WA3zoscCe1rIXnkAs?= =?us-ascii?Q?TEY+0gJ23zuVPMWcKh95aCLUfMwqjxNB3NTQHKgMk8RpBB/NgbXS7+waROG3?= =?us-ascii?Q?hv+KhUrhASa+GOBTmWPaCYoD5KDJS0FpUJLxHCe4KLZosir23Hd0uj0OBRH3?= =?us-ascii?Q?j6iwFkdhNHb2qzTQ/YjUxPxHeXdWLQbkVZhRanmpjkctgwGQigSzkPddOT5p?= =?us-ascii?Q?q/eWHp0ZbouGCQSy27MjuZAm50zkX61NH8mIXYAnYnxXbfgABCj/R4DSS/qD?= =?us-ascii?Q?OACfQt8Eslcfk3ZgGh7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-ascii?Q?sHJ5jEadry00g11J8Hp+NZA+EhlTwjpgrNf6qYfUkZeGt7Oske4RYnlYaYrW?= =?us-ascii?Q?iDjAjPxaxkc2EHEPGMvPrNDzc7LbBdhuuOt+IPFBRWJz1KnhN4Wg1CiGZJTY?= =?us-ascii?Q?XedxRQ6OHMr1ObtCs/oQ45JHebmMe6aLuqULrYm+EU9S1ybpLPVvhXK8eYTn?= =?us-ascii?Q?iwd4sDOElL0Wfrkk+0Uy2vgClQ6afHZwCyU92o7XVjO3U8rANEhM5GE/lPHZ?= =?us-ascii?Q?HfliTfdXDvmL5OJrnHok9atSsxtyl3tkwho0WDJx4WCfJdzpIRUCse6U7pSu?= =?us-ascii?Q?6pfMlHv1M5I34Nk3AkZpisb3WzAepeSgePWG76iUrquSN9q6CoAnx0AGUcvV?= =?us-ascii?Q?JaEpxgGdl/84c+RggQn4DBHRe7Ktqu8xmxuJ/KDlEh7yNz8+PKon/gYc4SjC?= =?us-ascii?Q?iFf7gcQQn+vkxJ46m3CoRDbce3ETYJkHqXUwz+3PGdL5eFzJ9UloDXgYbUFd?= =?us-ascii?Q?hG6/Lz6nhdspcJhtX1h+EUQYhscWd40=3D?= X-OriginatorOrg: cgstowernetworks.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71a1a30a-5577-431f-5d6c-08da51d67cbf X-MS-Exchange-CrossTenant-AuthSource: AM0PR09MB3972.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2022 09:31:28.5207 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fc9e9498-07e8-4b82-b4cf-365bba23cbbf X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UYvBMaH5cU7QcIpvOSNl6CoWL/CaPJHFzf27eYNeISiP/qlBJ9Qzq6BBJirMudqsKbNV1BesPmCr0axLK5JP3rZD2/huudyCh7Fqsk3G86g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR09MB5056 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Support rte_eth_dev_set_mtu for pcap ifaces vdevs by setting the underlying OS network interface's MTU. Support is for pcap ifaces only and not for pcap files. Support is for Linux only. Bugzilla ID: 961 Signed-off-by: Ido Goshen --- doc/guides/rel_notes/release_22_07.rst | 3 ++ drivers/net/pcap/pcap_ethdev.c | 42 ++++++++++++++++++++++++++ drivers/net/pcap/pcap_osdep.h | 1 + drivers/net/pcap/pcap_osdep_freebsd.c | 7 +++++ drivers/net/pcap/pcap_osdep_linux.c | 21 +++++++++++++ drivers/net/pcap/pcap_osdep_windows.c | 7 +++++ 6 files changed, 81 insertions(+) diff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst index 0ed4f92820..a354144044 100644 --- a/doc/guides/rel_notes/release_22_07.rst +++ b/doc/guides/rel_notes/release_22_07.rst @@ -95,6 +95,9 @@ New Features * Added AH mode support in lookaside protocol (IPsec) for CN9K & CN10K. * Added AES-GMAC support in lookaside protocol (IPsec) for CN9K & CN10K. +* **Updated pcap driver.** + + * Added support for MTU on Linux network interfaces. Removed Items ------------- diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c index ec29fd6bc5..2221c53051 100644 --- a/drivers/net/pcap/pcap_ethdev.c +++ b/drivers/net/pcap/pcap_ethdev.c @@ -807,6 +807,47 @@ eth_stats_reset(struct rte_eth_dev *dev) return 0; } +static int +eth_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) +{ + unsigned int i; + struct pmd_internals *internals = dev->data->dev_private; + int is_supported = 0; + int is_err = 0; + + for (i = 0; i < dev->data->nb_rx_queues; i++) { + struct pcap_rx_queue *queue = &internals->rx_queue[i]; + + if ((strcmp(queue->type, ETH_PCAP_IFACE_ARG) == 0) || + (strcmp(queue->type, ETH_PCAP_RX_IFACE_ARG) == 0) || + (strcmp(queue->type, ETH_PCAP_RX_IFACE_IN_ARG) == 0)) { + is_supported = 1; + if (osdep_iface_mtu_set(queue->name, mtu) < 0) + is_err = 1; + } + } + + for (i = 0; i < dev->data->nb_tx_queues; i++) { + struct pcap_tx_queue *queue = &internals->tx_queue[i]; + + if ((strcmp(queue->type, ETH_PCAP_IFACE_ARG) == 0) || + (strcmp(queue->type, ETH_PCAP_TX_IFACE_ARG) == 0)) { + is_supported = 1; + if (osdep_iface_mtu_set(queue->name, mtu) < 0) + is_err = 1; + } + } + + if (!is_supported) + return -ENOTSUP; + + if (is_err) + return -1; + + PMD_LOG(INFO, "MTU set %s %u\n", dev->device->name, mtu); + return 0; +} + static inline void infinite_rx_ring_free(struct rte_ring *pkts) { @@ -1004,6 +1045,7 @@ static const struct eth_dev_ops ops = { .link_update = eth_link_update, .stats_get = eth_stats_get, .stats_reset = eth_stats_reset, + .mtu_set = eth_mtu_set, }; static int diff --git a/drivers/net/pcap/pcap_osdep.h b/drivers/net/pcap/pcap_osdep.h index bf41cba982..043677ec77 100644 --- a/drivers/net/pcap/pcap_osdep.h +++ b/drivers/net/pcap/pcap_osdep.h @@ -14,5 +14,6 @@ extern int eth_pcap_logtype; int osdep_iface_index_get(const char *name); int osdep_iface_mac_get(const char *name, struct rte_ether_addr *mac); +int osdep_iface_mtu_set(const char *name, uint16_t mtu); #endif diff --git a/drivers/net/pcap/pcap_osdep_freebsd.c b/drivers/net/pcap/pcap_osdep_freebsd.c index 20556b3e92..a9961ba3e3 100644 --- a/drivers/net/pcap/pcap_osdep_freebsd.c +++ b/drivers/net/pcap/pcap_osdep_freebsd.c @@ -57,3 +57,10 @@ osdep_iface_mac_get(const char *if_name, struct rte_ether_addr *mac) rte_free(buf); return 0; } + +int +osdep_iface_mtu_set(__rte_unused const char *if_name, __rte_unused uint16_t mtu) +{ + PMD_LOG(ERR, "mtu set not supported on freebsd\n"); + return -ENOTSUP; +} diff --git a/drivers/net/pcap/pcap_osdep_linux.c b/drivers/net/pcap/pcap_osdep_linux.c index 97033f57c5..b0b4a716fe 100644 --- a/drivers/net/pcap/pcap_osdep_linux.c +++ b/drivers/net/pcap/pcap_osdep_linux.c @@ -40,3 +40,24 @@ osdep_iface_mac_get(const char *if_name, struct rte_ether_addr *mac) close(if_fd); return 0; } + +int +osdep_iface_mtu_set(const char *if_name, uint16_t mtu) +{ + struct ifreq ifr; + int if_fd = socket(AF_INET, SOCK_DGRAM, 0); + + if (if_fd == -1) + return -1; + + rte_strscpy(ifr.ifr_name, if_name, sizeof(ifr.ifr_name)); + ifr.ifr_mtu = mtu; + if (ioctl(if_fd, SIOCSIFMTU, &ifr)) { + PMD_LOG(ERR, "%s mtu set to %d failed\n", if_name, mtu); + close(if_fd); + return -1; + } + + close(if_fd); + return 0; +} diff --git a/drivers/net/pcap/pcap_osdep_windows.c b/drivers/net/pcap/pcap_osdep_windows.c index 1d398dc7ed..db34fc49e2 100644 --- a/drivers/net/pcap/pcap_osdep_windows.c +++ b/drivers/net/pcap/pcap_osdep_windows.c @@ -116,3 +116,10 @@ osdep_iface_mac_get(const char *device_name, struct rte_ether_addr *mac) free(info); return ret; } + +int +osdep_iface_mtu_set(__rte_unused const char *device_name, __rte_unused uint16_t mtu) +{ + PMD_LOG(ERR, "mtu set not supported on Windows\n"); + return -ENOTSUP; +} -- 2.17.1