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 C7472A0543; Tue, 7 Jun 2022 08:27:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 753BE4021D; Tue, 7 Jun 2022 08:27:44 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2135.outbound.protection.outlook.com [40.107.22.135]) by mails.dpdk.org (Postfix) with ESMTP id 2D2B540156 for ; Tue, 7 Jun 2022 08:27:43 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XyP3v+tuU6orWLeLmdslmETK2zR9rA7ykBLP+vRYLVSNfABmNgSaSPxa4IUOf3soMjhncJ6yAoo13Rimz1cUajL/uU4fqprMSScHH1dgGLSwehvblYqz5DV/9B8Z8r4j/LUQ6lZW7liuTrBstp1gNEhnDTVurHeZMeY2x8dE53z0ScUEdO3+n6cSqsqnJJZbbvuKy3HhaIfWIqAzuxhisceJv0M/LTNr0UiWO3AG7VAZOGwy/Pwaxf3YRKrMhpFOyblb3nPQ6QG8YFU6uG7e+Ywkj8OEryyCNqrrXbfWMLfSNA0PDDjuRINoigSbVpv6+2Esb/J1xqQtGEWbs/m6tA== 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=zJgdC8IMxbjYm6nhEl3FlCe9l0yanHfIzkMMIk5hhPE=; b=jdjD6TwTI5zyxLxGc1pJlR9jhWxuR/6ayYyKsMKsMeIhmYrQV05R8yre58QbrbXnJCxCaeUpSLg7cKkR/tC/V4QmC0IjpT/ZP4AeAJxhcfZTN+a5akCWPCibQ2i8E3l3211csZhGalaszM08/GCT6K+yi4LfKhvRtkFcGFibrSzXb+u4sVC1JY26CHMfuuyo8iAm+cVI6HSXRqE2lkONVnjCV8+KYbBbEA372eSM9TQGrCik87VZP338qb3oK53Wnea+VRrsf870swXFUyjtiVW26dY+75NC3C3W6i2FdaBKwkRDYHhV1aERExebxBjIeVMYjq6uHIaIGtWAWjiqiQ== 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=zJgdC8IMxbjYm6nhEl3FlCe9l0yanHfIzkMMIk5hhPE=; b=iqtL9W4siOEASTSHW1BPLnmVYw1uC26a1EVNGed2h1q2AFzOuBvR1knjPPGonc4bbRPFLrKQX4/jhcP88w069UkkJ2RQPOvi5AAbCL4roDzjZiiaDxdiBRIw31Pl6XpbWe+gwIL3J2ZNl6B7NL4bCsu/nOIo8QZ74n0yJ6Phm94= 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 DB8PR09MB3722.eurprd09.prod.outlook.com (2603:10a6:10:111::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Tue, 7 Jun 2022 06:27:42 +0000 Received: from AM0PR09MB3972.eurprd09.prod.outlook.com ([fe80::d0d6:ba99:48ac:5e72]) by AM0PR09MB3972.eurprd09.prod.outlook.com ([fe80::d0d6:ba99:48ac:5e72%6]) with mapi id 15.20.5314.019; Tue, 7 Jun 2022 06:27:41 +0000 From: Ido Goshen To: ferruh.yigit@xilinx.com, stephen@networkplumber.org Cc: dev@dpdk.org, Ido Goshen Subject: [PATCH v5] pcap: support MTU set for linux interafces Date: Tue, 7 Jun 2022 09:27:28 +0300 Message-Id: <20220607062728.9439-1-ido@cgstowernetworks.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220317174347.110909-1-ido@cgstowernetworks.com> References: <20220317174347.110909-1-ido@cgstowernetworks.com> Content-Type: text/plain X-ClientProxiedBy: VI1P195CA0009.EURP195.PROD.OUTLOOK.COM (2603:10a6:800:d0::19) 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: 2e813f21-4f28-439f-3099-08da484ed32c X-MS-TrafficTypeDiagnostic: DB8PR09MB3722: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: nyKStaySe1c1OQW23VYRWFGcQE/Yb4O0f18As9JNknUl6Ua1+zfZnLq2w3CVYHqCYngVzfWCA+7rp0aK3RV/5C0aH1qECQh2Ud9lnTkFlUDz3bPFjeDJ/836UcRAdsgRtBvE8YwqnzR3Rp0zS3h6ZcG/gLW6Y96aRCCu2ZSRWaBvjiKvTr5zu5sTJjZWh3fytQel7NNdBBmA02t5no+nfUTBUrXWL+9QUCoT2havo7M3V0Ba5P7x0ec9S6auiwTiyK4L8bdf2j2nYpch47XwUR2S26E4vHV40Qk6KNzi7dZPQ996IVpFboTh9IaTcUTsHH4n20E7ajbPvxi5JMJqbQfLDFudOBXvY3jDcVUSqx7s3SXXgT2/ngON7yMEWwlSlNFsAWFzIwAfq409mPXiq2/forVQ3KaVq1zSDNtYEQZ9CCrrnGurzB36QFnndBX5LBx83eRUahVM5r5ZOj8tNFNJB6gDEDTeG9hZwq4ccGtseyzbBjpLFBqwf6YIoS82Rin/FxWeCgM4xaZbGKRcme984TsbPlT0rJzQ5y6b+lFoFUTZ+zRYH2LYZzYg4JJgXAaogntNXcnAQLGqQZiABKG3Aph3S+wNrLRBu7DqJTFdz7zUUSPMStZKnJEJR18fsh5Ffam104CbbddpzgC82hfcsewpFfV/yjF9hH8Kaiyl+7BkJPW6s1PvK5R+QBAcpnsRTZtPZcbMOsusHEE5Cg== 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:(13230001)(39830400003)(136003)(346002)(366004)(376002)(396003)(38100700002)(2906002)(8936002)(36756003)(107886003)(316002)(5660300002)(66476007)(26005)(6512007)(4326008)(66946007)(83380400001)(8676002)(1076003)(6506007)(52116002)(66556008)(41300700001)(6666004)(2616005)(508600001)(86362001)(6486002)(186003)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?VfGuGdRFnL4LNklpfaZQfbHcrIazT7X1YM5F9DOhcbPXZ5pASMvBNEXSel5G?= =?us-ascii?Q?WO+gJuXyrIPCKa6v8vsyckCECL4lyrNsGY4y/cnL/Mpc80uWMXZBC/7Ue0dc?= =?us-ascii?Q?us++IR1jbzb+XY6Snj1MT8+ukMObIkXC4/4uQ9oDcVlf7NsQnbIUcOfJ+IlJ?= =?us-ascii?Q?IzzUPAlOt9AYwKK8WYg3FTQcuP9o6I+i/GV+hYxcAw9wv1PRpa1K2vnCpmDW?= =?us-ascii?Q?KZSGP3YfwDhELbtWGvLIxfbBG8f9tVum+lYeytUyyy7gFcninXa6gni+hMUr?= =?us-ascii?Q?aMsuUNpJytPkoIQODBDPKVxFkBY1GkjWZO1eLX8IC2qcro8Bum+B1jaj7Jz0?= =?us-ascii?Q?Y2mCy71aJS6IpFlyDASO7xPKxxNy+9whE3Keae0MRaSYItUue66662DMWVul?= =?us-ascii?Q?xWm2KNDn23WgfL86k5CtIXaJBwIp5K+OzEyjIvZGupkm946fCc8/hpQ59oR3?= =?us-ascii?Q?LE8N2Rv3wHOPTFoWLMRSLM8ELM6s+jORxUxF42Eg+3lQE9myaV0lPItFAmGd?= =?us-ascii?Q?4oK2Z2TEff/S+cMPAw/g6KlKiwNuRVp+VnHFpcQn+9sVWja0KsKBVd6yVI3h?= =?us-ascii?Q?iCzHu27zKbsfPOp4ussyZfA9r+Lhq/BayMkTzuW2dTrHr76hBwce/chpD2s3?= =?us-ascii?Q?rqB25QoRMDk3KZUPPVG1Omqes+2awTxOfRboRYw7M65JcqQkKitfC5Jkyha1?= =?us-ascii?Q?OhZO6Q+N44fGACXep+y5Ce7RA3npOf0T5kNShif4K2OCVwbFozFG89kRrk+V?= =?us-ascii?Q?+hzvmASTXKGtdIK4sFhSI+eewi6plfVRjqMdvdb0/9mRwWhgt9gkYcfL3NqU?= =?us-ascii?Q?GredB84lCord3//LcOJObnmBZ54RosFTueotOUi3zhQV/+dPKhtnO8jWs78G?= =?us-ascii?Q?TIxGc30tyDuN4q8YvvTmXzsR6RG4kJRwkUwSshRWXGWJ4nScg7e2BXFFmi6Y?= =?us-ascii?Q?CVpvjVsCrLhM6f41E2E9xGNM4WGFMrjKr9Ha6+mYyMSdua/PIfNn3t02bAsm?= =?us-ascii?Q?9sd071kTaVMweYdDMETlGdBSIfvHT73mIUTEYcLstKzACzc+AZi1IcQjMT0o?= =?us-ascii?Q?Xh5i/xzxgzMKbexaq1qN2PMvXo+vlaMN01NSM15WlX+WOhn5DGo7awD+klSk?= =?us-ascii?Q?ZEgL0+4wXugX2tZbeXGvRcI3ms0eNDRs9JjcRoc6GxAEZe22t8ar2CupRVai?= =?us-ascii?Q?9gh7yWn6Th48mfZKXxNQRyuBrOd4rerAalX7uTDU1XD8/VFvTvleowiqJFSG?= =?us-ascii?Q?4dzO3EX+QKfGXOllS/edVSqTBAQq4/f4Hjmd4JDWczrQUm6SSeEy9ArYLFJ2?= =?us-ascii?Q?UXjOaPgajHjoSZK8kKa9L4hf7kzKCD18IX+EaE6JaFxZQsfvmluN6xX0pME4?= =?us-ascii?Q?KfF9J/Md/b7U4Xb6O1ouaiYmd+hrplBvfFBfx7LPvU1jH7MHG99CKC7fZW3I?= =?us-ascii?Q?o6M7ODo+TLaQJAGUHg0RdlGuMCdw7Ltu871BIe+XOK16QLqaHAG/5ffm1Tcc?= =?us-ascii?Q?V/552ScBrtBWS8n0ot4Mp0hVX/Y9FUqF8dhJncnlpbvSxBFA8GPOV7k55qol?= =?us-ascii?Q?pErmKkYgnu0fn/Ubm66NqA/oGX+KtGdwjkTLOY4HakwhfxORkafYck6CyUgf?= =?us-ascii?Q?iBIbKd38rXVMnXU2X/F0LAquxKb86yZHMgDiCBIQSKbm3oe6+iK2soGShNOJ?= =?us-ascii?Q?nZtRNiBc0vt4ybIb1OV5WBooN2bRw6IFuim7ixzbyOaM9RJazCy46gci9Njz?= =?us-ascii?Q?RYFKnuuzOE9fZItAND3M8MIv2RbEMiM=3D?= X-OriginatorOrg: cgstowernetworks.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e813f21-4f28-439f-3099-08da484ed32c X-MS-Exchange-CrossTenant-AuthSource: AM0PR09MB3972.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2022 06:27:41.8726 (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: X4uLdiJCuJCzCnEKdLr16LcWXx/RsAWsKbX3T+VEoEBv458gNYpi7IHCDf5AjGOqbdpKGvOfOta1KNFsU4T6FcvnisHu03RWVSuwTwTkU+c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR09MB3722 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 --- v5: Alternative approach Instead of checking MTU in the pmd set it on the OS interface and let it do the enforcment. v4: 1. Add release notes comment 2. Access pmd internals via queue struct 3. eth_mtu_set code convention fixes v3: Preserve pcap behavior to support max size packets by default alternative to v2 in order to limit the code change to pcap only and avoid abi change. Enforce mtu only in case rte_eth_dev_set_mtu was explicitly called. v2: Preserve pcap behavior to support max size packets by default. --- doc/guides/rel_notes/release_22_07.rst | 3 ++ drivers/net/pcap/pcap_ethdev.c | 43 ++++++++++++++++++++++++++ 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, 82 insertions(+) diff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst index 0ed4f92820..b90cfefc55 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..3d76d50ef1 100644 --- a/drivers/net/pcap/pcap_ethdev.c +++ b/drivers/net/pcap/pcap_ethdev.c @@ -807,6 +807,48 @@ 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 +1046,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..ef8be7543c 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 *if_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..52d4a0e6db 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(const char *if_name, uint16_t mtu) +{ + PMD_LOG(WARN, "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..15205a521e 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(const char *if_name, uint16_t mtu) +{ + PMD_LOG(WARN, "mtu set not supported on Windows\n", sys_ret); + return -ENOTSUP; +} -- 2.17.1