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 58C0FA04FD; Wed, 8 Jun 2022 18:05:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E82C44069C; Wed, 8 Jun 2022 18:05:22 +0200 (CEST) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10134.outbound.protection.outlook.com [40.107.1.134]) by mails.dpdk.org (Postfix) with ESMTP id C36EA40687 for ; Wed, 8 Jun 2022 18:05:21 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A4cuYb2TJeKjGI1vslnoTdelWQvBe3Smb2wiJF0a0IQz6UfgcNU+9Zur4RTxPdBdP8Px8SQdckpt9CobSafbSBHu9sRxUoaBRVx5bH6DcCLhfwWTUUNoT7rjRuAPYzjhV5T1QUXE0QOCAsFtE+j5yD5g7qDsnBnNyNj2qll9Vvirch4UmoGaji3G0omfcxoDpIVhhVVQRBsGe/H5j95EM7Nvaui7VmbEDSmgz/cWkea+2WlQmaZCnN6/2KpMKLSEWm4qpRMfgSMG3jfSrZJnLK/Ue/jZ4DlVjW65EecbZwHb5LpAGTSPLXvpnPpNtz9XSJyVgQxn9FpxXyfnFOChkQ== 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=pnblTBMQ975WzEeU/7kQhDEJywOn3h2nSIPYii2KXiA=; b=Orc0lkIXi4FJWZWABuvFicWOKcn+XerQg+89y9hFfJuHsHV4FoBsTlLun4RDmm11czlF+J1IfWHVO5OUKIxlB7nJougOqQmnD15yzdz6sto0Gmv5zgt+L9CYrlAQ1E2/zzJZSfaV3Wt6bAKa2dAyGPc69FhqjKfBZuMavrvpnVAS/vYj3ji6cZLGqeQfc6+GREFOPlqbcetvojoI4iNbUqBJjQ9Pw36A4wTzbhIdcxb4EjxKh4EvA6Jsg1UsK1e9CfcoBjOc0dYB3R+2xaU/JpKuD1cCPqlP72cvLhWnLZfpHgSiNHMPmI6wJo7HZOtSAXKG1zmBZ3DvquWatuRByw== 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=pnblTBMQ975WzEeU/7kQhDEJywOn3h2nSIPYii2KXiA=; b=XNsXTKlKtT1J6OodnJMgNcg+3bfoDa8kltbOXEVVu0UG8bLWsBl8OVPoo0xrXnAtb8PrsvAGCHr0nkxWUeMQX+QwQThAebBh+t0d+5dLBoyTb+HStg/JnOpKaf2HM4JnGRwdv3wfOaCdS+MqSnIQm7W+goIA3ik1cy8Vg3lwJJs= 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 VI1PR09MB2494.eurprd09.prod.outlook.com (2603:10a6:803:83::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.17; Wed, 8 Jun 2022 16:05:20 +0000 Received: from AM0PR09MB3972.eurprd09.prod.outlook.com ([fe80::d0d6:ba99:48ac:5e72]) by AM0PR09MB3972.eurprd09.prod.outlook.com ([fe80::d0d6:ba99:48ac:5e72%7]) with mapi id 15.20.5332.012; Wed, 8 Jun 2022 16:05:20 +0000 From: Ido Goshen To: ferruh.yigit@xilinx.com, stephen@networkplumber.org Cc: dev@dpdk.org, Ido Goshen Subject: [PATCH v6] pcap: support MTU set for linux interafces Date: Wed, 8 Jun 2022 19:04:19 +0300 Message-Id: <20220608160419.94063-1-ido@cgstowernetworks.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220607062728.9439-1-ido@cgstowernetworks.com> References: <20220607062728.9439-1-ido@cgstowernetworks.com> Content-Type: text/plain X-ClientProxiedBy: VI1PR0801CA0089.eurprd08.prod.outlook.com (2603:10a6:800:7d::33) 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: c595319b-71c3-44e8-5a7f-08da4968afcc X-MS-TrafficTypeDiagnostic: VI1PR09MB2494: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: xYY/wX0qBXj/6DtpRCaR0pUBW64oN9jOviTvDPMykzphbzCTVZiAaJKpXl1mIakiODh2oirqtUMp5PZ/a07DnQEQXyl4+3ZyRWdYtpx1VhJa6KU5EQIWSPXMHmL/U3N1cJEz1SM/XHr4Yl+XiP2DWyxf1pe5lJfQQGq0DnZNHMtlZ2zg09hcoMPhvSkQtIPK4fBtBd9uDNhAkaVYUhBG5Ahydu9SHraNnd8FCb4OhEtogfoi8256s0dE3Ljy2YVwNZ5/rPAz3uMYR+Ky9sR+9CnIax3973mF7LkTz7B4PKJaulVyTGgHWFVloRPa6iRfC/TpikB+K5OU16jtkhG7KvpoQGFULcunBqZmO+EXFexY/IVe6I5I24pTtqbKNLXgqnERPBHAyWfHgzmfwad9VCyizZlFe792salvGCJvGif6cmOpdn31lGgqBzZySHIyrWSOIls1G8TJd3pu4eNSpL9cWvGX+tFgGIyzrIDX4iB8rCCb7efrIpLLn/FLPgtIsUP3Ig2x1rAwYfZUY/D0M8QA2IHsxvrhduj/xAUvMRdi/+UHx8D2zxJCzxPXgjEm4pZbjbGDurXPZGyRTAdkkqfTibcuz4Sn896ZlIVIBnCEVm4XOIkqyTvNZicTmPNx2uy/s8XAH377aXI5H+h/2xwhL9g+0fV5koLAMpJAXT4tB2FPtGVjWg98GldTUP4SzARoFqVAmagDU3EcMYosOw== 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)(396003)(39830400003)(346002)(136003)(366004)(38350700002)(2616005)(8936002)(186003)(66476007)(66556008)(5660300002)(2906002)(86362001)(316002)(8676002)(4326008)(508600001)(1076003)(38100700002)(6486002)(107886003)(36756003)(66946007)(83380400001)(6506007)(52116002)(6512007)(26005)(41300700001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?plCSdjpyZ71hUuB893A0VWw+XZrZAW/siGQ7nejYK6TUFedSmEDVs2Y8z90u?= =?us-ascii?Q?4ugj60hbE46GwIXhoUni/6x45k1fJ0R6gn5ZbbRgkOuNvZHqn9YlNBnrGVXN?= =?us-ascii?Q?EFfYg2dGEX1JoqIdUaIc0o74PLGAaR8Hk36GWC2vsUBPokcK4TJ/bpCt9xLb?= =?us-ascii?Q?QSl3VoC6qZgZDMJdhvXl3n8gsG7SYr8Y8nYk2jrySXbGTbk9Ee8tnlHxU95C?= =?us-ascii?Q?ZBL9mBhJYA2wxJTIWmE4snzZAPqxDnX2J6W95wLN2EojG8O83Ls6yH4e3L/M?= =?us-ascii?Q?82T12hrwaKuADn4cZ1mh/QbiIkWzPcxNO6Wv1YqDZYYwDpvV8PAZfF0SO1hk?= =?us-ascii?Q?6D4af+3fWnp9cpYjRh6L8/JwH9J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mrjIoOR6RXSN7ANL/1/cKQZdVOIVFouJ3xgpF+vFIVogyPwZMcgNPWtK0d17?= =?us-ascii?Q?LhQ1rD7fb/C/ATDduwXmSWOunDk/li7YEHJLfj4kunAqvKAvRKjxppWVmJLa?= =?us-ascii?Q?f3t8uUSw3Y126KvirUEy7Ryy4naexxViaoVyTmfLOfzt/fNIu5Ze5c3rHmRJ?= =?us-ascii?Q?d6va7iI+5NtZfD3QNHTjbamELW4xdjtQApRMKIRZt3CsWjDIZbALgHHSqwA8?= =?us-ascii?Q?1OfHjxLHPA2Fr8pcut+RZJBg6qBPzp10sPRaFzcpQAuwuxN730gwuAoxgt8D?= =?us-ascii?Q?FeB2GUsVUrcLsqDYOie845+3v34IxhoHenC5A1eGkeI3PGtvLTkKf9pnIj+b?= =?us-ascii?Q?afTkQViKTjsZ06xYWUAK0PDMfvc841a/Y8PIgNrHak4vcpV88M6GeJVYogHc?= =?us-ascii?Q?pRZ6seAtvQequBC9K08+JJXFA2VPfx6O3NVlHD1TziyD79krt8wHVTmuaEml?= =?us-ascii?Q?sTFC5PYcvSyMES7Smo6z+UfVE2/Yfe8=3D?= X-OriginatorOrg: cgstowernetworks.com X-MS-Exchange-CrossTenant-Network-Message-Id: c595319b-71c3-44e8-5a7f-08da4968afcc X-MS-Exchange-CrossTenant-AuthSource: AM0PR09MB3972.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2022 16:05:20.3364 (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: WO3+wrdRAxKHTOwTljdeX+P/nz6upTMYIuAdEPoYcpc4AlPemoDzkVq1OmuSSyuMCf+vdM9eX1vytksJVSxhhSqPYEEhsZjiRTIelxrlQj0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR09MB2494 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 --- v6: Fixes for v5 approach 1. freebsd compilation fix 2. checkpatch warning fix 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 | 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..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..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..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..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..69cf052e6d 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 *if_name, __rte_unused uint16_t mtu) +{ + PMD_LOG(ERR, "mtu set not supported on Windows\n"); + return -ENOTSUP; +} -- 2.17.1