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 7652AA0545; Mon, 20 Jun 2022 10:40:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1980F40F19; Mon, 20 Jun 2022 10:40:42 +0200 (CEST) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70137.outbound.protection.outlook.com [40.107.7.137]) by mails.dpdk.org (Postfix) with ESMTP id 2383340150 for ; Mon, 20 Jun 2022 10:40:41 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gO6NB5IT0Y0Avv9NP/iEOWISo3tpmibmpK4r+EWhA2BRsaGwAERFLtP0Wcmhyh3Io19ulvrc4aKyfPDWHqT/WOlPIM0zQZOSWLjMfR2l/nUryEq6E6OG+Nwm15v+eZPJHnJSH+aUzxajNXVnuTs6hTwH4Abwc3pdAQcRDDE+zNEJH/qrTHgJOCYUmHOe8CD9ToV05LEaAszrAN77TTz0AFI8Bh9yxjWK1dnGbLGXMJ/s7YtrOK2LHJYWFboNWPvPVj72opzDPRc2tV0QXpUa6gz7IPgxy/nbhna/xm3rnohcfLQFsVaC1MSVzuZskLjSWeehz20nhzVULCz0C3MbKA== 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=87TqE+LOF//CNMEG5+1wWKCDgtTgUEOY2oq+Wn/3akU=; b=Y8jhrsxRZruVkQwfVdElBsi6Ti7YNKqAHU1RkC6SvOBw0YME64YrrsE+RZtO8ns4xRwMAARjVcvQrqphZc/sRh+dS+feOn7fx3kO0yevOfHpVpSqq3KkOK7fUueD4Xmt2ZT/BnSU1pI39Biin0MW7oZGhMdUf9NRKZH2gxZuqsqcIz6cqcLsKjXz+sFlMcXaVbVmuvcr2kQ73PDCClxJSRZEpt81rFC6Qv2T3fJnXz6qcHwupfkKF0gkmzwZ4DnDOzF4MrfRbpgq7VQf/JFn+HyuR0GYxUX8a70B4jenP/nfd47a7yf8r9e6UwZQ2Jjhh8HjsYLOy6YS8aLeXnrcSA== 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=87TqE+LOF//CNMEG5+1wWKCDgtTgUEOY2oq+Wn/3akU=; b=OSyxYUV6vVuCCB3QhxKVA9vR8N71i5OJ+X9qislWkcG8FpqW7WEx5W6JzJK2bGXJmLax//a9XgDZ7kxiEmblxHvVUc1ZlAeNZCXzEC4OJ3QExtcmyXaL7j60DLx5gs9pEihVmzq/mW7I0CIfAXXG49X1kFo5eFhSpKbVMnZtym8= 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 AM6PR09MB2824.eurprd09.prod.outlook.com (2603:10a6:20b:a5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.13; Mon, 20 Jun 2022 08:40:40 +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.022; Mon, 20 Jun 2022 08:40:39 +0000 From: Ido Goshen To: ferruh.yigit@xilinx.com, stephen@networkplumber.org Cc: dev@dpdk.org, Ido Goshen Subject: [PATCH v8 1/3] pcap: support MTU set for linux interfaces Date: Mon, 20 Jun 2022 11:39:42 +0300 Message-Id: <20220620083944.51517-2-ido@cgstowernetworks.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220620083944.51517-1-ido@cgstowernetworks.com> References: <20220317174347.110909-1-ido@cgstowernetworks.com> <20220620083944.51517-1-ido@cgstowernetworks.com> Content-Type: text/plain X-ClientProxiedBy: VI1PR04CA0122.eurprd04.prod.outlook.com (2603:10a6:803:f0::20) 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: 47a990ba-a429-4435-612b-08da52988dea X-MS-TrafficTypeDiagnostic: AM6PR09MB2824: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: hraO+aFkIYYE7zGf+GZTxjqR0eHK9VuU3auawSQR2rQiy07wN4/aYHmC4iZpwJoYitD/EDdNM68nFGX4fRLzZMvMPwQj9oTOVvVChI4DJJwd/HE2bBEFUxRKJVj/6YnL8SScwiP1o/qsaQ4ZEcV6NYd/IdmiulhwM96W2JydgLh+1ZhyuAUDx6s6CFkbvt1sMTtGI5i2qi0rGlW+tgPBlTzcjOdrUFVunU9S8bqsHwiDdeJgOJ+apYIy3HW2xn98tB64lKWA/ZjeYQnaRSMQ3HqTaxLAqRZcZp5wnIxsxHQoPF501E5iWtjZtxUniF7w70J+iZjOXM/d8tMO8Abo3+Pss0/bCueei4Ak3uii5ZkArClC7UnZZJlDf0LI2M0vXx09VtgQ0LYPlxaKwZoCr0/0pHCJNa4KcBjlju3lOnI+AUX3WkC9TrbhZrMYcIwYgF2Nxm/4Wea2anrkQ8cRT3AUekKHqLvbNLK+rD4Lr+SPSxndl8wGtiZjPdw6glFj8aKhqv7C7sE6+c0zoNb7pzObjaKqly3RWbc01Y6h95UcnL+RB5yaIY6pTtorcpzJOeA2xU8Eh7KmqOnqdT2DjZRSbQJ8RZvUMOsdqOvJyEWn2E8IMiL7DOApcRnSfK81llvE73dkWvN+dUqMABmnJl99m4DKz+Rvty6F3UhKmYtTzD2msaaORB6AQz7RB6vjgBzM3REgAi4McQVMD5GQrg== 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)(136003)(39830400003)(376002)(396003)(346002)(366004)(6512007)(478600001)(8936002)(41300700001)(8676002)(6506007)(52116002)(316002)(6486002)(36756003)(26005)(6666004)(2616005)(4326008)(186003)(83380400001)(66556008)(66946007)(107886003)(66476007)(1076003)(38350700002)(86362001)(5660300002)(2906002)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?UnoBeKtd6YP7SWlHNvv69VFpxpbjjDltt08ZZAMjTG0MZjEwmYYtBZ/osOtF?= =?us-ascii?Q?q/mPwmprE4C6XS0mjyMQRi0NpdrkMhOuGhV/XvZOLtnjDhtw+s+mxOG6apd/?= =?us-ascii?Q?cz6n8ZqOT5AG9e7NlHg2WYF7+iZIfllqK3QaI7E3yyDS44xW9PltBmPiy9DP?= =?us-ascii?Q?VykGHhVyeCRLPvU1RZxsGhIjcUj0tWabIuFnFv8mgQfQEiepBFNQT8zX+WFi?= =?us-ascii?Q?/wXZXIr2v1g9Ja95qYaqboTjOVmw639Qnta2Fk1kaNlueQMpwhoVHL6MUaAA?= =?us-ascii?Q?kWgHFpgfo+HijGZudh425jkD+G+88SK0XNhQ3oRKwJD3agB7bHP2v4b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byA2hCcwhtkvxUbycWKz73Gt52B/ixL?= =?us-ascii?Q?DqoN6+FZ8xtm20RXTTHiWBQujm7U6bDf+D4EuCmWXFYc/y6wuvhO+KMFoi3d?= =?us-ascii?Q?lIlrEdUDYxx2xxXuG61iIjha8/mis0wRlLgIhaLKHx41uecvpsYQ9NKrE5Pg?= =?us-ascii?Q?FZwpmrmv+Myq469tE1DkxUUIx8Ez7vSKRgat24M2KNJT13nYBhGq3TT7sYvv?= =?us-ascii?Q?qa+7Ty/pQ7lxwV6iQBvfYXSk2zDfnmaDcA07Ikmp5DSXgLzJkLmTgFkSGtOe?= =?us-ascii?Q?cKaKxoS6vCi6uGNarAejKMxlkiD4gDxRtVGDNfBphA4VOA8Kh4udtcfcylWx?= =?us-ascii?Q?yaTB0yUJJydQHBx0fmqWhyyTG9vVJ5edNKSEAkWOtktvSqsZnm34mzjzNUWJ?= =?us-ascii?Q?ogG243T71s8TfBv8yPlaLDVPoDZlBc2GQ39PLQQgLOfMiP9MJCjZQXf/zuOA?= =?us-ascii?Q?B4XylZRKhQyrtNAOEyi2bp9ZrpWQSCVi1mBCGAlOPXvgYc93VZWIPkZREiIj?= =?us-ascii?Q?konCZNkOMnrV4UJridqK1yTXCPzvN0c=3D?= X-OriginatorOrg: cgstowernetworks.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47a990ba-a429-4435-612b-08da52988dea X-MS-Exchange-CrossTenant-AuthSource: AM0PR09MB3972.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2022 08:40:39.7675 (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: dH6O4/X7S6eV4/ByCdTh0YA+MOb4fyhUM3nkKck4OYTmfiOgYDu+uCpypaOVCEOmExvsIH7SAVqrcYEFATfXjXMIj83IcIlaCoQhfyLG4IE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR09MB2824 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 dd371952c3..a966973302 100644 --- a/doc/guides/rel_notes/release_22_07.rst +++ b/doc/guides/rel_notes/release_22_07.rst @@ -220,6 +220,9 @@ New Features Merged l3fwd-acl code into l3fwd as l3fwd-acl contains duplicate and common functions to l3fwd. +* **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