Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp826452pxb; Wed, 15 Sep 2021 14:20:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydzYaXrEXtK87UG5YNTMysqSoD6SA2XgCEUUiFIe+ZIoAgavlBpGLq1bFgsFaV2Wt8Eo3h X-Received: by 2002:a05:6638:1484:: with SMTP id j4mr1757870jak.80.1631740807564; Wed, 15 Sep 2021 14:20:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631740807; cv=none; d=google.com; s=arc-20160816; b=VRl6LrmKcfv/ZwoTJVo5Sn40y1slSPdqdS851k9YaKUGSbgABfgNSzyztU5rQYIqUv 9AS6EW+g/4UPT24nFbArngqhMBVHpgv4QJ9aNKbu16eNAZSnHKbmGkG+7eAocarcey46 +jfiZR8UpGASkWYbMc+0ZfhglFCrp0xYY5YS2l9LL/ExzxRmcoSxkaHN07dxjRY4cDHn FNt2SGKy1C9GqMQynFQHSZIatkHCbFY6XFgBAqSKwLVqX8QPlGSq4jFdt4Al2uAbaEWY 1R5lUgxovcL0GdBukXljoF964Wt8YqzwAa1PiH98wYiRD8AS75Jfr8Q2uV+zSzGOWXc8 7eIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=r86CNqldwDEtT67/MPxr+lwRy10J2msOmuDKCgTFsHA=; b=M7xPxrGybmyjVoz5MaoR1Pmr+zbiSChZVJu6Y819keQdZS5FdqmMebe/QRGQRhNv8e IxF7VqCbdjmWLrwlHv/yx+PzMI33KwE5vF3/Le4KJjcsgX2yG6+F3U5sH0pqRCdl4MS9 L1eFnW6mv8QXY1fo7MUW7GA8aXjarOV46fq+IutoRpYmazgxM7PSsL+25gP8NNgk2UIU 7hubtxFG0sDuCLcYCpapiOq6EW/EkcMUxEqLFlAY6dWJ+t4APFSVBN97cHhTJTBP+YGN W0jMsHrc1Q8IcvOTeHOR3QLBJqhk+E8+7fR4edQHRMOkZB8bERTIURQw2uTBmI3O0ek+ Dhfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="Am1/doWw"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t6si878632jaa.130.2021.09.15.14.19.56; Wed, 15 Sep 2021 14:20:07 -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=@lunn.ch header.s=20171124 header.b="Am1/doWw"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232202AbhIOVSt (ORCPT + 99 others); Wed, 15 Sep 2021 17:18:49 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:43122 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230382AbhIOVSb (ORCPT ); Wed, 15 Sep 2021 17:18:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=r86CNqldwDEtT67/MPxr+lwRy10J2msOmuDKCgTFsHA=; b=Am1/doWwxRfmJugYmt746kUzi2 m/4EPXqeca+ZsOZGRhMDWkPqhbZ0UlQ7VUWfneEXaVAau35yEHLQY3ZXiNul3WZaux6VuZlJMS05K lbCW5X8QMJ9Cl1ZVpQEQgr5o10FOpcndhBlCUxWLJMTq7Z20PW+wiJNLo7YzZ959FYDA=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1mQcHB-006oEm-4f; Wed, 15 Sep 2021 23:17:05 +0200 Date: Wed, 15 Sep 2021 23:17:05 +0200 From: Andrew Lunn To: Stefan Wahren Cc: "David S. Miller" , Jakub Kicinski , Rob Herring , Michael Heimpold , jimmy.shen@vertexcom.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH RFC 3/3] net: vertexcom: Add MSE102x SPI support Message-ID: References: <20210914151717.12232-1-stefan.wahren@i2se.com> <20210914151717.12232-4-stefan.wahren@i2se.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210914151717.12232-4-stefan.wahren@i2se.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > + > +#define MSG_DEFAULT (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | \ > + NETIF_MSG_TIMER) > + > +#define DRV_NAME "mse102x" > + > +#define DET_CMD 0x0001 > +#define DET_SOF 0x0002 > +#define DET_DFT 0x55AA > + > +#define CMD_SHIFT 12 > +#define CMD_RTS (0x1 << CMD_SHIFT) > +#define CMD_CTR (0x2 << CMD_SHIFT) > + > +#define CMD_MASK GENMASK(15, CMD_SHIFT) > +#define LEN_MASK GENMASK(CMD_SHIFT - 1, 0) > + > +#define DET_CMD_LEN 4 > +#define DET_SOF_LEN 2 > +#define DET_DFT_LEN 2 Looks like these tabs should be spaces? > +static int msg_enable; > +module_param_named(message, msg_enable, int, 0); > +MODULE_PARM_DESC(message, "Message verbosity level (0=none, 31=all)"); I know a lot of drivers do this, but module parameters are not liked. There is a well used ethtool setting for this, msglvl, which should be used instead. Which in fact, you have support for. > +static void mse102x_init_mac(struct mse102x_net *mse, struct device_node *np) > +{ > + struct net_device *ndev = mse->ndev; > + int ret = of_get_mac_address(np, ndev->dev_addr); > + > + if (ret) { > + eth_hw_addr_random(ndev); > + netdev_err(ndev, "Using random MAC address: %pM\n", > + ndev->dev_addr); > + } > +} No need to tell the hardware? Does it work in promiscuous mode by default? > +static int mse102x_net_stop(struct net_device *ndev) > +{ > + struct mse102x_net *mse = netdev_priv(ndev); > + struct mse102x_net_spi *mses = to_mse102x_spi(mse); > + > + netif_info(mse, ifdown, ndev, "shutting down\n"); > + > + netif_stop_queue(ndev); > + > + /* stop any outstanding work */ > + flush_work(&mses->tx_work); > + > + /* ensure any queued tx buffers are dumped */ > + while (!skb_queue_empty(&mse->txq)) { > + struct sk_buff *txb = skb_dequeue(&mse->txq); > + > + netif_dbg(mse, ifdown, ndev, > + "%s: freeing txb %p\n", __func__, txb); > + > + dev_kfree_skb(txb); > + } > + > + free_irq(ndev->irq, mse); > + > + return 0; Maybe a netif_carrier_off() in there, to be symmetric with open? > +/* ethtool support */ > + > +static void mse102x_get_drvinfo(struct net_device *ndev, > + struct ethtool_drvinfo *di) > +{ > + strscpy(di->driver, DRV_NAME, sizeof(di->driver)); > + strscpy(di->version, "1.00", sizeof(di->version)); > + strscpy(di->bus_info, dev_name(ndev->dev.parent), sizeof(di->bus_info)); > +} Version is pretty pointless. We suggest you don't use it. The ethtool core will then fill it with the kernel version, > +static int mse102x_probe_spi(struct spi_device *spi) > +{ ... > + netif_carrier_off(mse->ndev); > + ndev->if_port = IF_PORT_10BASET; That is not correct. Maybe you should add a IF_PORT_HOMEPLUG ? > + ndev->netdev_ops = &mse102x_netdev_ops; > + ndev->ethtool_ops = &mse102x_ethtool_ops; > + > + mse102x_init_mac(mse, dev->of_node); > + > + ret = register_netdev(ndev); > + if (ret) { > + dev_err(dev, "failed to register network device: %d\n", ret); > + return ret; > + } > + > + mse102x_init_device_debugfs(mses); > + > + return 0; > +} > +static const struct of_device_id mse102x_match_table[] = { > + { .compatible = "vertexcom,mse1021" }, > + { .compatible = "vertexcom,mse1022" }, Is there an ID register you can read to determine what device you actually have? If so, i suggest you verify the correct compatible is used. Andrew