Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp159013pxj; Wed, 26 May 2021 19:08:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbfVQLQotYoQ4XTn+3pE9UBTETl2mfaP9Wqhk4FAdTtKULAp1Dd0bkbbpMAGAndvRkF8Dc X-Received: by 2002:a17:906:c0c9:: with SMTP id bn9mr1320178ejb.7.1622081314770; Wed, 26 May 2021 19:08:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622081314; cv=none; d=google.com; s=arc-20160816; b=IVMtEwWz6E8PlmVPMH9FQWG2Fto1RWFalMtU0uBxnppVIpTpHhZ57/JwyQBBNfE8AA wW6vLF9Q0m2KKPnat0HB/QQklOEB73uUVlEg9cq6BQ8Jss338GzPVfL7NuCl+DaXTis7 aHpfCStXi8raLgUAXnHcGj8JtleAhL568fJHQdPV6R9olEvD4Kc9zWYchhkGHEK+qzpk jslHohTw8VEFjzKolZqohXhOge4YvqLNa+ADjHccqcVV7Z41iHmBSBaVyNa4nYapnDz3 M5fJxKTKrL2n/dbeeb/gn8n/5iRtfZu+8nIraRCA1JWmXhxM6qp0ci982ZAyYndDRCyf PQUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=AiN8gajS1iaz7VAHXQBLGHKX2gaBgIiDln2cnqjicQc=; b=fP/r2I4XWQHKpSWnp/O7j3xqiyezxHSLi+NgMgVuVL/n7yMx7meepQ7jDMTOucHPik FJcKgnw1GTwQKjKFgFQ4ByeZWT04+bhyOa6dy4Gp3UWJqpxXghZ2N6cQBukwWFjAOs0q Gu0MCF31W2EFU3qs95weN9UaWDFPfI75tiZycpm1Tl+3v773aka5RdB5NRJvz1GMapk3 cRc0PInNprDEm/tNH2p2CREkgkwe3CK/4i6IZvhwci1BSiastCDASUmtL0nPbs7OBuw4 tRy1WuASunEyP6GLmYXRlW3Ppg9Cj+mZR3e3KG1AxJYFGUQtrQSJ7P1W9udiy62/coqM xQKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l25si751164ejr.631.2021.05.26.19.08.06; Wed, 26 May 2021 19:08:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233054AbhE0Bld (ORCPT + 99 others); Wed, 26 May 2021 21:41:33 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:5562 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232262AbhE0Blc (ORCPT ); Wed, 26 May 2021 21:41:32 -0400 Received: from dggems705-chm.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Fr9R60ypkzjX8v; Thu, 27 May 2021 09:37:06 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggems705-chm.china.huawei.com (10.3.19.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 27 May 2021 09:39:58 +0800 Received: from [127.0.0.1] (10.69.26.252) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Thu, 27 May 2021 09:39:58 +0800 Subject: Re: [RFC net-next 1/4] ethtool: extend coalesce API To: Jakub Kicinski CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , References: <1622021262-8881-1-git-send-email-tanhuazhong@huawei.com> <1622021262-8881-2-git-send-email-tanhuazhong@huawei.com> <20210526165633.3f7982c9@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> From: Huazhong Tan Message-ID: <87bc57e0-1c37-1867-d958-fcfdda9ac743@huawei.com> Date: Thu, 27 May 2021 09:39:57 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <20210526165633.3f7982c9@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.69.26.252] X-ClientProxiedBy: dggeme720-chm.china.huawei.com (10.1.199.116) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On 2021/5/27 7:56, Jakub Kicinski wrote: > On Wed, 26 May 2021 17:27:39 +0800 Huazhong Tan wrote: >> @@ -606,8 +611,12 @@ struct ethtool_ops { >> struct ethtool_eeprom *, u8 *); >> int (*set_eeprom)(struct net_device *, >> struct ethtool_eeprom *, u8 *); >> - int (*get_coalesce)(struct net_device *, struct ethtool_coalesce *); >> - int (*set_coalesce)(struct net_device *, struct ethtool_coalesce *); >> + int (*get_coalesce)(struct net_device *, >> + struct netlink_ext_ack *, > ext_ack is commonly the last argument AFAIR. yes, will fix it. >> + struct kernel_ethtool_coalesce *); > Seeing all the driver changes I can't say I'm a huge fan of > the encapsulation. We end up with a local variable for the "base" > structure, e.g.: > > static int wil_ethtoolops_set_coalesce(struct net_device *ndev, > - struct ethtool_coalesce *cp) > + struct netlink_ext_ack *extack, > + struct kernel_ethtool_coalesce *cp) > { > + struct ethtool_coalesce *coal_base = &cp->base; > struct wil6210_priv *wil = ndev_to_wil(ndev); > struct wireless_dev *wdev = ndev->ieee80211_ptr; > > so why not leave the base alone and pass the new members in a separate > structure? This is a similar approach as struct ethtool_link_ksettings suggested by Michal in last year's discussion. https://lore.kernel.org/lkml/20201119220203.fv2uluoeekyoyxrv@lion.mk-sys.cz/ add a new separate structure can make less change. like below what we have to do is just add a new parameter. static int wil_ethtoolops_set_coalesce(struct net_device *ndev, -                       struct ethtool_coalesce *cp) +                       struct ethtool_coalesce *cp, +                       struct ethtool_ext_coalesce *ext_cp, +                       struct netlink_ext_ack *extack) {      struct wil6210_priv *wil = ndev_to_wil(ndev);      struct wireless_dev *wdev = ndev->ieee80211_ptr; If this is ok, i will send a V2 for it. >> + int (*set_coalesce)(struct net_device *, >> + struct netlink_ext_ack *, >> + struct kernel_ethtool_coalesce *); >> void (*get_ringparam)(struct net_device *, >> struct ethtool_ringparam *); >> int (*set_ringparam)(struct net_device *, >> static noinline_for_stack int ethtool_set_coalesce(struct net_device *dev, >> void __user *useraddr) >> { >> - struct ethtool_coalesce coalesce; >> + struct kernel_ethtool_coalesce coalesce; >> int ret; >> >> if (!dev->ethtool_ops->set_coalesce) >> return -EOPNOTSUPP; >> >> - if (copy_from_user(&coalesce, useraddr, sizeof(coalesce))) >> + if (copy_from_user(&coalesce.base, useraddr, sizeof(coalesce.base))) >> return -EFAULT; >> >> if (!ethtool_set_coalesce_supported(dev, &coalesce)) >> return -EOPNOTSUPP; >> >> - ret = dev->ethtool_ops->set_coalesce(dev, &coalesce); >> + ret = dev->ethtool_ops->set_coalesce(dev, NULL, &coalesce); >> if (!ret) >> ethtool_notify(dev, ETHTOOL_MSG_COALESCE_NTF, NULL); >> return ret; > Should IOCTL overwrite the settings it doesn't know about with 0 > or preserve the existing values? IOCTL will overwrite the setting with random value, will a get_coalesce before copy_from_user() to fix it. Thanks. Huazhong. > .