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 933AD45B42; Tue, 15 Oct 2024 17:26:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2B80E400D7; Tue, 15 Oct 2024 17:26:53 +0200 (CEST) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by mails.dpdk.org (Postfix) with ESMTP id 2247E400D6 for ; Tue, 15 Oct 2024 17:26:52 +0200 (CEST) Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-20cdda5cfb6so24235925ad.3 for ; Tue, 15 Oct 2024 08:26:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1729006011; x=1729610811; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=FDfKX1KR8kQND5bdDfIX69QmM0gywY7EMk1wY3ZhPac=; b=uchikUDicXCs/aXhjudPhlfsJdPx9gb/JwpJLqUhAXXLbp2IY7ytl2UDdkKnWjPsnO 5m7vpFdYl1i26y1R3uK7/HfGYtrQ4ujsvst8HNzZWszn66xfG+sxk/lBw9/JS+mhnA82 du+ApOTRAXxlTRB1kKz7d6mjAcaughPQz1blIAIHRcvasC5nFBL4+o3W3iI9YVcwDPXG jZA/F+/hdUFI3/e09Xlb72lew5COfI/nJYN1CA0R0zpOlk4Q5mkeGEeDkXlesdBDuN38 PQkpuOkDZZrn5NjrDG9FIUJCjeavsz9lbnAHm3rUNTuQ3kqdkd82VP4GE37ZqLaAOXQg wTxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729006011; x=1729610811; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FDfKX1KR8kQND5bdDfIX69QmM0gywY7EMk1wY3ZhPac=; b=Gl0Ji2rXtv7ThYuGOb7tYOXxLg6bEFKakkyJUE3i1HGx61YaqivMQaKgqOSspAkzVH wRDo2h+c4aQgo/bpC3O6zeEwK/5t0hGCyxtCU6byfCfXd0WXxy62sX9RwS89yZt0iqAv 7h0QjNGXwmKMWmuJRSQuXZiyrzLniXnXKj/jwo2+8tAYTuKG4HBqhDCKM9chFbAtUeMd ELuYcFhhuQf/GauNSuFbGfMdzU0FfuNzVLhw5g97EwAj9i6spc7vBmXhkDU4UbY3iuVK EiHe+atyWFv49QhE3/ZaoSeV+bw1zHdcjcQ8c9W6mF4Z/yXQLgtmdt+WHAP9r6Q8NHcI T9pA== X-Gm-Message-State: AOJu0YyQEz1uD27DRoXoQcEyFGx7PTwJZw6YjvBC6Lmca+cCJuWI7vIW +ECmJVlvNgUqFvY30AKb4wTT5AEWEbQFF4Uw+b2APffy9F17BxIvTGEtGnjAU6bDeoLFHvRuiC6 M X-Google-Smtp-Source: AGHT+IHrikiGDm3ov3QV+AQtljwAc85ISc8EIB6668qD5z+vrP0KkvuKgyfdZIar20psKhSizRfq/A== X-Received: by 2002:a17:903:32cd:b0:20b:c258:2a74 with SMTP id d9443c01a7336-20ca148bf3cmr187776745ad.29.1729006011216; Tue, 15 Oct 2024 08:26:51 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20d18036251sm13362215ad.172.2024.10.15.08.26.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 08:26:51 -0700 (PDT) Date: Tue, 15 Oct 2024 08:26:48 -0700 From: Stephen Hemminger To: Howard Wang Cc: , Subject: Re: [PATCH v1 15/18] net/r8169: impelment MTU configuration Message-ID: <20241015082648.39684562@hermes.local> In-Reply-To: <20241015030928.70642-16-howard_wang@realsil.com.cn> References: <20241015030928.70642-1-howard_wang@realsil.com.cn> <20241015030928.70642-16-howard_wang@realsil.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 On Tue, 15 Oct 2024 11:09:25 +0800 Howard Wang wrote: > +static int > +rtl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) > +{ > + struct rte_eth_dev_info dev_info; > + struct rtl_adapter *adapter = RTL_DEV_PRIVATE(dev); > + struct rtl_hw *hw = &adapter->hw; > + int ret; > + uint32_t frame_size = mtu + RTL_ETH_OVERHEAD; > + > + ret = rtl_dev_infos_get(dev, &dev_info); > + if (ret != 0) > + return ret; > + > + if (mtu < RTE_ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) > + return -EINVAL; > + This validation is already done in ethdev, not needed here. int rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu) { ... ret = rte_eth_dev_info_get(port_id, &dev_info); if (ret != 0) return ret; ret = eth_dev_validate_mtu(port_id, &dev_info, mtu); if (ret != 0) return ret; static int eth_dev_validate_mtu(uint16_t port_id, struct rte_eth_dev_info *dev_info, uint16_t mtu) { uint32_t overhead_len; uint32_t frame_size; if (mtu < dev_info->min_mtu) { RTE_ETHDEV_LOG_LINE(ERR, "MTU (%u) < device min MTU (%u) for port_id %u", mtu, dev_info->min_mtu, port_id); return -EINVAL; } if (mtu > dev_info->max_mtu) { RTE_ETHDEV_LOG_LINE(ERR, "MTU (%u) > device max MTU (%u) for port_id %u", mtu, dev_info->max_mtu, port_id); return -EINVAL; }