Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4849634pjb; Mon, 27 Jul 2020 06:47:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwceN0P3Eup4ieXEpY7VX1zlpdjCB8MhizMmJtFoWmIOLCtoCOX5tur2wvgCV11AtlkDnpB X-Received: by 2002:a05:6402:cb9:: with SMTP id cn25mr21915039edb.247.1595857640739; Mon, 27 Jul 2020 06:47:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595857640; cv=none; d=google.com; s=arc-20160816; b=k2RXroo5BjFvkIMKqe9moRRVS26NKqXv+048hoyllSKHCviaA6KmeJa4vqtVCsknhk yU2xfe24/BshZXRF2z9jJTly8/Ry0aCA8ldd6mlJ4iKdxKhhISo70iYcfbDQ8UE32WXT 5n5Og8a3QPfKmvtuTZowGgzGQ8xMeN92snuij1L3kxb/VlKs5ahogg616t0FChb15MIA 3L0zkRPIqc6g8+o6Hp3wr1SwS4HSteg0H0cMQ9ht0y3fWviclbbtKXbmCNwoc5PwO05k DeEep9IB8rOXBDZgGqhfU3bYzgt0GMsa97yCKAa+P6sHhysC2OwMX1sjxt0hNs5Ea9iI 1Uig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=5M1ztqlAmxsfJxB6TYJ36mBz6BebKaVLzv7BqF77ask=; b=dETE0usicLSqV3Ug3QBFfP6qAnXIJbn4PeOz7s1AIks0bly1D/xypfSHfnjHIkiBDE lk8qKx0HIoPG7aWMH/qBj+PMWkcZ3cAxoCEH61SIAkxIlAhOoCWWzVpcbhEsmidJUzbP yyYs8gKMzw23DJq5OtXiSuGbDi405OwTr9KdpMOhbAWL/Z3FNzqpGO8vG/PIBxvO0PDM Ch0wDCMomyGJOXP4g0VgMvQxrA1VEn9196M8NVsiQeUeGgW01/gcuRFWn0+LHi34Z+V0 8QsUUFikOIn4VFpMIR21vmQWtPlS6X+c5bcKuIhBxjvckklnmo6r0q2G2Wz4kyDUBVIm zTqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DhUKGdN9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs4si2408380ejb.104.2020.07.27.06.46.58; Mon, 27 Jul 2020 06:47:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DhUKGdN9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728646AbgG0NRU (ORCPT + 99 others); Mon, 27 Jul 2020 09:17:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727120AbgG0NRU (ORCPT ); Mon, 27 Jul 2020 09:17:20 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25761C061794; Mon, 27 Jul 2020 06:17:20 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id b9so7977187plx.6; Mon, 27 Jul 2020 06:17:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5M1ztqlAmxsfJxB6TYJ36mBz6BebKaVLzv7BqF77ask=; b=DhUKGdN9GVxPl/HxJBHias4O/OdYHRowok0FHtqa3zT9v4UZkPcobizy2rRTmDK7iT J1j9Y1QQTya37khlE5r6QbrW+gQOAjgYgEboqVUHnA2thT3jvMbei8bCcJYzECoChx1k 2UaBvnnYKiMmT3CqpT0fYpmQQqcpy82WAhfcwTPPWJAYeK6p7rG2S/k+33amqJjAXiPf hFeORVrQF6iIGqf3tzlO8tFFCFe4aN3acVxKJv1/aKzIqCv4YnGkOXmA0hsv0MQvR0PM cTpUPjEUclGB6v0wYW/jNL9EZRnubd/8kZv8l25zikID3j6NgqxIan4BXQIuDGFe4GAj MO0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5M1ztqlAmxsfJxB6TYJ36mBz6BebKaVLzv7BqF77ask=; b=Y5D/z2PC214pFZ4zR3EnaEdwgjqhuqqub24tvR/EAMrPCgcXHyrVZxL4yCT3t5SZmC D6xqt3ywTr1m2R9befGSSc7EyvXlIJv0SshNxGRPO6p6lyeiyN0CM6LRuMA/Qwawce8y CTFymhPVSfo8wBZPDklVdLAch3WXosdCvO/vfSUt3JPzL+Ur0fLJ783Zc7PfLcvQ/Orf ZvOSPyQjHAzGFu5eqtyFAo9CkxXs0mzOoMFAo0hKOWfgEMltPYLnEmxO3NGtHCPOYfXq J5ZoocHsUr61WxzQX43uQVpwXoluLUwM3sXJB8nBLaXmFjvdrOEa687wvPs7cEBDy3qh mOsw== X-Gm-Message-State: AOAM531PDK57Py3nSTIICCoB2dVCToWvn8opzVDAiDr16NbeuJhtWE15 4nxiHZ9kpeNJyrLqaG233yxtTMXwhiFB8D7JfwA= X-Received: by 2002:a17:90a:a393:: with SMTP id x19mr16478818pjp.228.1595855839567; Mon, 27 Jul 2020 06:17:19 -0700 (PDT) MIME-Version: 1.0 References: <20200727122242.32337-1-vadym.kochan@plvision.eu> <20200727122242.32337-5-vadym.kochan@plvision.eu> In-Reply-To: <20200727122242.32337-5-vadym.kochan@plvision.eu> From: Andy Shevchenko Date: Mon, 27 Jul 2020 16:17:04 +0300 Message-ID: Subject: Re: [net-next v4 4/6] net: marvell: prestera: Add ethtool interface support To: Vadym Kochan Cc: "David S. Miller" , Jakub Kicinski , Jiri Pirko , Ido Schimmel , Andrew Lunn , Oleksandr Mazur , Serhiy Boiko , Serhiy Pshyk , Volodymyr Mytnyk , Taras Chornyi , Andrii Savka , netdev , Linux Kernel Mailing List , Mickey Rachamim Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 27, 2020 at 3:23 PM Vadym Kochan wrote: > > The ethtool API provides support for the configuration of the following > features: speed and duplex, auto-negotiation, MDI-x, forward error > correction, port media type. The API also provides information about the > port status, hardware and software statistic. The following limitation > exists: > > - port media type should be configured before speed setting > - ethtool -m option is not supported > - ethtool -p option is not supported > - ethtool -r option is supported for RJ45 port only > - the following combination of parameters is not supported: > > ethtool -s sw1pX port XX autoneg on > > - forward error correction feature is supported only on SFP ports, 10G > speed > > - auto-negotiation and MDI-x features are not supported on > Copper-to-Fiber SFP module ... > + if (new_mode < PRESTERA_LINK_MODE_MAX) > + err = prestera_hw_port_link_mode_set(port, new_mode); > + else > + err = -EINVAL; > + > + if (!err) { > + port->caps.type = type; > + port->autoneg = false; > + } > + > + return err; Again if (new_mode >= ...) return -EINVAL; err = ... if (err) return err; ... return 0; ... > + ecmd->base.speed = !err ? speed : SPEED_UNKNOWN; Why not positive conditional? ... > + if (!prestera_hw_port_duplex_get(port, &duplex)) { Ditto. ... > +static int > +prestera_ethtool_set_link_ksettings(struct net_device *dev, > + const struct ethtool_link_ksettings *ecmd) > +{ > + struct prestera_port *port = netdev_priv(dev); > + u64 adver_modes = 0; > + u8 adver_fec = 0; Redundant assignments? > + int err; > + > + err = prestera_port_type_set(ecmd, port); > + if (err) > + return err; > + > + if (port->caps.transceiver == PRESTERA_PORT_TCVR_COPPER) { > + err = prestera_port_mdix_set(ecmd, port); > + if (err) > + return err; > + } > + > + prestera_modes_from_eth(ecmd->link_modes.advertising, &adver_modes, > + &adver_fec, port->caps.type); > + return 0; > +} ... > + struct prestera_msg_port_attr_req req = { > + .attr = PRESTERA_CMD_PORT_ATTR_REMOTE_CAPABILITY, > + .port = port->hw_id, > + .dev = port->dev_id + comma > + }; ... > + struct prestera_msg_port_attr_req req = { > + .attr = PRESTERA_CMD_PORT_ATTR_REMOTE_FC, > + .port = port->hw_id, > + .dev = port->dev_id Ditto. > + }; ... > + switch (resp.param.fc) { > + case PRESTERA_FC_SYMMETRIC: > + *pause = true; > + *asym_pause = false; > + break; > + case PRESTERA_FC_ASYMMETRIC: > + *pause = false; > + *asym_pause = true; > + break; > + case PRESTERA_FC_SYMM_ASYMM: > + *pause = true; > + *asym_pause = true; > + break; > + default: > + *pause = false; > + *asym_pause = false; > + } > + > + return err; return 0; ... > +int prestera_hw_port_type_get(const struct prestera_port *port, u8 *type) > +{ > + struct prestera_msg_port_attr_req req = { > + .attr = PRESTERA_CMD_PORT_ATTR_TYPE, > + .port = port->hw_id, > + .dev = port->dev_id > + }; > + return err; Same comments as above. And seems more code needs the same. > +} ... > +static u8 prestera_hw_mdix_to_eth(u8 mode) > +{ > + switch (mode) { > + case PRESTERA_PORT_TP_MDI: > + return ETH_TP_MDI; > + case PRESTERA_PORT_TP_MDIX: > + return ETH_TP_MDI_X; > + case PRESTERA_PORT_TP_AUTO: > + return ETH_TP_MDI_AUTO; > + } > + > + return ETH_TP_MDI_INVALID; Use the default case. > +} > + > +static u8 prestera_hw_mdix_from_eth(u8 mode) > +{ > + switch (mode) { > + case ETH_TP_MDI: > + return PRESTERA_PORT_TP_MDI; > + case ETH_TP_MDI_X: > + return PRESTERA_PORT_TP_MDIX; > + case ETH_TP_MDI_AUTO: > + return PRESTERA_PORT_TP_AUTO; > + } > + > + return PRESTERA_PORT_TP_NA; Ditto. > +} -- With Best Regards, Andy Shevchenko