Skip to contentSkip to conversation

*** ADD DM9051 NET DEVICE ***

PATCH Superseded Joseph CHANG 5 participants 8 messages Dec 8, 2021 – Dec 9, 2021

Subsystems (3)

v1 of 20 Superseded Latest is v20 →

lore
Share & tools
lore
#0 lore raw

cover *** ADD DM9051 NET DEVICE ***

*** DM9051 is a SPI interface ethernet controller chip *** *** For a embedded Linux device to construct an ethernet port *** *** Fewer CPU interface pins is its advantage comapre to DM9000 *** *** It need only cs / mosi / miso / clock and an interrupt pin ***

Joseph CHANG (2):
yaml: Add dm9051 SPI network yaml file
net: Add DM9051 driver

 .../bindings/net/davicom,dm9051.yaml          |  62 ++
 drivers/net/ethernet/davicom/Kconfig          |  30 +
 drivers/net/ethernet/davicom/Makefile         |   1 +
 drivers/net/ethernet/davicom/dm9051.c         | 987 ++++++++++++++++++
 drivers/net/ethernet/davicom/dm9051.h         | 259 +++++
 5 files changed, 1339 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/davicom,dm9051.yaml
 create mode 100644 drivers/net/ethernet/davicom/dm9051.c
 create mode 100644 drivers/net/ethernet/davicom/dm9051.h

base-commit: ce83278f313ce65a9bbd780a3e07fa3f62d82525

Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 yaml: Add dm9051 SPI network yaml file

For support davicom dm9051 device tree configuration

---
 .../bindings/net/davicom,dm9051.yaml          | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/davicom,dm9051.yaml
Documentation/devicetree/bindings/net/davicom,dm9051.yaml new file +62 -0
new file mode 100644
index 000000000000..10db5aae20ba
@@ -0,0 +1,62 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/davicom,dm9051.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Davicom DM9051 SPI Ethernet Controller
+
+maintainers:
+  - Joseph CHANG <[email protected]>
+
+description: |
+  The DM9051 is a fully integrated and cost-effective low pin count single
+  chip Fast Ethernet controller with a Serial Peripheral Interface (SPI).
+
+properties:
+  compatible:
+    const: davicom,dm9051
+
+  reg:
+    maxItems: 1
+
+  spi-max-frequency:
+    maximum: 45000000
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - spi-max-frequency
+  - interrupts
+
+allOf:
+  - $ref: ethernet-controller.yaml#
+
+additionalProperties: false
+
+examples:
+  - |
+    /* for Raspberry Pi with pin control stuff for GPIO irq */
+    spi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        dm9051@0 {
+            compatible = "davicom,dm9051";
+            reg = <0>; /* spi chip select */
+            pinctrl-names = "default";
+            pinctrl-0 = <&eth_int_pins>;
+            interrupt-parent = <&gpio>;
+            interrupts = <26 IRQ_TYPE_LEVEL_LOW>;
+            spi-max-frequency = <31200000>;
+        };
+    };
+    gpio {
+        eth_int_pins {
+            brcm,pins = <26>;
+            brcm,function = <0>; /* in */
+            brcm,pull = <0>; /* none */
+        };
+    };
\ No newline at end of file
Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [PATCH 1/2] yaml: Add dm9051 SPI network yaml file

Quoted 8 lines · Joseph CHANG

For support davicom dm9051 device tree configuration

---
 .../bindings/net/davicom,dm9051.yaml          | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/davicom,dm9051.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:
./Documentation/devicetree/bindings/net/davicom,dm9051.yaml:62:7: [error] no new line character at the end of file (new-line-at-end-of-file)

dtschema/dtc warnings/errors:
Error: Documentation/devicetree/bindings/net/davicom,dm9051.example.dts:29.34-35 syntax error FATAL ERROR: Unable to parse input tree
make[1]: *** [scripts/Makefile.lib:373: Documentation/devicetree/bindings/net/davicom,dm9051.example.dt.yaml] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1413: dt_binding_check] Error 2

doc reference errors (make refcheckdocs):
Documentation/Makefile:39: The 'sphinx-build' command was not found. Make sure you have Sphinx installed and in PATH, or set the SPHINXBUILD make variable to point to the full path of the 'sphinx-build' executable.

Detected OS: DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.3 LTS".
Warning: better to also install "convert".
Warning: better to also install "dot".
Warning: better to also install "dvipng".
ERROR: please install "ensurepip", otherwise, build won't work.
Warning: better to also install "fonts-dejavu".
Warning: better to also install "fonts-noto-cjk".
Warning: better to also install "latexmk".
Warning: better to also install "rsvg-convert".
Warning: better to also install "xelatex".
You should run:

sudo apt-get install imagemagick graphviz dvipng python3-venv fonts-dejavu fonts-noto-cjk latexmk librsvg2-bin texlive-xetex
note: If you want pdf, you need at least Sphinx 2.4.4.
To upgrade Sphinx, use:

Can't build as 2 mandatory dependencies are missing at ./scripts/sphinx-pre-install line 953.

	/usr/bin/python3 -m venv sphinx_2.4.4
	. sphinx_2.4.4/bin/activate
	pip install -r ./Documentation/sphinx/requirements.txt

If you want to exit the virtualenv, you can use:
deactivate

See https://patchwork.ozlabs.org/patch/1565174

This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit.

#3 lore raw

PATCH 2/2 net: Add DM9051 driver

In reply to Joseph CHANG

Add davicom dm9051 SPI ethernet driver. The driver work with some parameters, such as:

- spi bus number

- spi chip select

- spi clock frequency

- interrupt gpio pin

Interrupt polarity fixed to low.
Test OK with Raspberry Pi 2 and Pi 4 as well for its broadcom CPUs. This driver can work to many other CPUs too, since it independently uses the lower spi control functions that are provided from the CPU vendors.

---
 drivers/net/ethernet/davicom/Kconfig  |  30 +
 drivers/net/ethernet/davicom/Makefile |   1 +
 drivers/net/ethernet/davicom/dm9051.c | 987 ++++++++++++++++++++++++++
 drivers/net/ethernet/davicom/dm9051.h | 259 +++++++
 4 files changed, 1277 insertions(+)
 create mode 100644 drivers/net/ethernet/davicom/dm9051.c
 create mode 100644 drivers/net/ethernet/davicom/dm9051.h
drivers/net/ethernet/davicom/Kconfig +30 -0
index 7af86b6d4150..9c00328f6e05 100644
@@ -3,6 +3,20 @@
 # Davicom device configuration
 #
 
+config NET_VENDOR_DAVICOM
+	bool "Davicom devices"
+	depends on ARM || MIPS || COLDFIRE || NIOS2 || COMPILE_TEST || SPI
+	default y
+	help
+	  If you have a network (Ethernet) card belonging to this class, say Y.
+
+	  Note that the answer to this question doesn't directly affect the
+	  kernel: saying N will just cause the configurator to skip all
+	  the questions about Davicom devices. If you say Y, you will be asked
+	  for your specific card in the following selections.
+
+if NET_VENDOR_DAVICOM
+
 config DM9000
 	tristate "DM9000 support"
 	depends on ARM || MIPS || COLDFIRE || NIOS2 || COMPILE_TEST
@@ -22,3 +36,19 @@ config DM9000_FORCE_SIMPLE_PHY_POLL
 	  bit to determine if the link is up or down instead of the more
 	  costly MII PHY reads. Note, this will not work if the chip is
 	  operating with an external PHY.
+
+config DM9051
+	tristate "DM9051 SPI support"
+	depends on SPI
+	select CRC32
+	select MII
+	help
+	  Support for DM9051 SPI chipset.
+
+	  To compile this driver as a module, choose M here.  The module
+	  will be called dm9051.
+
+	  The SPI mode for the host's SPI master to access DM9051 is mode
+	  0 on the SPI bus.
+
+endif # NET_VENDOR_DAVICOM
drivers/net/ethernet/davicom/Makefile +1 -0
index 173c87d21076..225f85bc1f53 100644
@@ -4,3 +4,4 @@
 #
 
 obj-$(CONFIG_DM9000) += dm9000.o
+obj-$(CONFIG_DM9051) += dm9051.o
drivers/net/ethernet/davicom/dm9051.c new file +987 -0

987 lines not on this page · raw message

drivers/net/ethernet/davicom/dm9051.h new file +259 -0

259 lines not on this page · raw message

Signature · 1 line
2.25.1
#4 lore raw

Re: [PATCH 2/2] net: Add DM9051 driver

Thank you for the patch! Perhaps something to improve:

Hi Joseph,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ce83278f313ce65a9bbd780a3e07fa3f62d82525]

url:    https://github.com/0day-ci/linux/commits/Joseph-CHANG/ADD-DM9051-NET-DEVICE/20211208-193833
base:   ce83278f313ce65a9bbd780a3e07fa3f62d82525
config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20211208/202112082228.stoSxUom-lkp(a)intel.com/config)
compiler: arceb-elf-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/9ee7a9a16698431c764b4b21a0839e87f3692078
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Joseph-CHANG/ADD-DM9051-NET-DEVICE/20211208-193833
git checkout 9ee7a9a16698431c764b4b21a0839e87f3692078
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash drivers/net/ethernet/davicom/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

drivers/net/ethernet/davicom/dm9051.c: In function 'dm9051_read_mac_to_dev':
drivers/net/ethernet/davicom/dm9051.c:255:35: error: assignment of read-only location '*(ndev->dev_addr + (sizetype)i)'

     255 |                 ndev->dev_addr[i] = ior(db, DM9051_PAR + i);
         |                                   ^
   drivers/net/ethernet/davicom/dm9051.c:260:43: error: assignment of read-only location '*(ndev->dev_addr + (sizetype)i)'
     260 |                         ndev->dev_addr[i] = ior(db, DM9051_PAR + i);
         |                                           ^
   drivers/net/ethernet/davicom/dm9051.c: In function 'dm_set_mac_lock':
>> drivers/net/ethernet/davicom/dm9051.c:341:57: warning: passing argument 3 of 'dm_write_eeprom_func' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     341 |                         dm_write_eeprom_func(db, i / 2, &ndev->dev_addr[i]);
         |                                                         ^~~~~~~~~~~~~~~~~~

drivers/net/ethernet/davicom/dm9051.c:156:73: note: expected 'u8 *' {aka 'unsigned char *'} but argument is of type 'const unsigned char *'
156 | static void dm_write_eeprom_func(struct board_info *db, int offset, u8 *data)
| ~~~~^~~~

vim +341 drivers/net/ethernet/davicom/dm9051.c

318
319 /* set mac permanently
320 */
321 static void dm_set_mac_lock(struct board_info *db)
322 {
323 struct net_device *ndev = db->ndev;
324
325 if (db->enter_setmac) {
326 int i, oft;
327
328 db->enter_setmac = 0;
329 netdev_info(ndev, "set_mac_address %02x %02x %02x %02x %02x %02x\n",
330 ndev->dev_addr[0], ndev->dev_addr[1], ndev->dev_addr[2],
331 ndev->dev_addr[3], ndev->dev_addr[4], ndev->dev_addr[5]);
332
333 /* write to net device and chip */
334 ADDR_LOCK_HEAD_ESSENTIAL(db); //mutex_lock
335 for (i = 0, oft = DM9051_PAR; i < ETH_ALEN; i++, oft++)
336 iow(db, oft, ndev->dev_addr[i]);
337 ADDR_LOCK_TAIL_ESSENTIAL(db); //mutex_unlock
338
339 /* write to EEPROM */
340 for (i = 0; i < ETH_ALEN; i += 2)

 > 341				dm_write_eeprom_func(db, i / 2, &ndev->dev_addr[i]);

342 }
343 }
344

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#5 lore raw

Re: [PATCH 2/2] net: Add DM9051 driver

In reply to Joseph CHANG
Thank you for the patch! Yet something to improve:

Hi Joseph,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on ce83278f313ce65a9bbd780a3e07fa3f62d82525]

url:    https://github.com/0day-ci/linux/commits/Joseph-CHANG/ADD-DM9051-NET-DEVICE/20211208-193833
base:   ce83278f313ce65a9bbd780a3e07fa3f62d82525
config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20211209/202112090508.QK50XeZi-lkp(a)intel.com/config)
compiler: arceb-elf-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/9ee7a9a16698431c764b4b21a0839e87f3692078
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Joseph-CHANG/ADD-DM9051-NET-DEVICE/20211208-193833 git checkout 9ee7a9a16698431c764b4b21a0839e87f3692078
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

drivers/net/ethernet/davicom/dm9051.c: In function 'dm9051_read_mac_to_dev':

>> drivers/net/ethernet/davicom/dm9051.c:255:35: error: assignment of read-only location '*(ndev->dev_addr + (sizetype)i)'
     255 |                 ndev->dev_addr[i] = ior(db, DM9051_PAR + i);
         |                                   ^
   drivers/net/ethernet/davicom/dm9051.c:260:43: error: assignment of read-only location '*(ndev->dev_addr + (sizetype)i)'
     260 |                         ndev->dev_addr[i] = ior(db, DM9051_PAR + i);
         |                                           ^
   drivers/net/ethernet/davicom/dm9051.c: In function 'dm_set_mac_lock':
   drivers/net/ethernet/davicom/dm9051.c:341:57: warning: passing argument 3 of 'dm_write_eeprom_func' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     341 |                         dm_write_eeprom_func(db, i / 2, &ndev->dev_addr[i]);
         |                                                         ^~~~~~~~~~~~~~~~~~

drivers/net/ethernet/davicom/dm9051.c:156:73: note: expected 'u8 *' {aka 'unsigned char *'} but argument is of type 'const unsigned char *'
156 | static void dm_write_eeprom_func(struct board_info *db, int offset, u8 *data)
| ~~~~^~~~

vim +255 drivers/net/ethernet/davicom/dm9051.c

245
246 /* functions process mac address is major from EEPROM
247 */
248 static int dm9051_read_mac_to_dev(struct device *dev, struct net_device *ndev,
249 struct board_info *db)
250 {
251 int i;
252 u8 mac_fix[ETH_ALEN] = { 0x00, 0x60, 0x6e, 0x90, 0x51, 0xee };
253
254 for (i = 0; i < ETH_ALEN; i++)

 > 255			ndev->dev_addr[i] = ior(db, DM9051_PAR + i);

256 if (!is_valid_ether_addr(ndev->dev_addr)) {
257 for (i = 0; i < ETH_ALEN; i++)
258 iow(db, DM9051_PAR + i, mac_fix[i]);
259 for (i = 0; i < ETH_ALEN; i++)
260 ndev->dev_addr[i] = ior(db, DM9051_PAR + i);
261 dev_info(dev, "dm9 [reg_netdev][%s][chip MAC: %pM (%s)]\n",
262 ndev->name, ndev->dev_addr, "FIX-1");
263 return 0;
264 }
265 return 1;
266 }
267

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#6 lore raw

Re: [PATCH 2/2] net: Add DM9051 driver

In reply to Joseph CHANG

drivers/net/ethernet/davicom/dm9051.c line 169

Quoted 3 lines
drivers/net/ethernet/davicom/dm9051.c new file +3 -0
+static int burst_xfer(struct board_info *db, u8 cmdphase, u8 *txb, u8 *rxb, unsigned int len)
+static int dm_phy_read_func(struct board_info *db, int reg)
+static int dm9051_phy_read_lock(struct net_device *dev, int phy_reg_unused, int reg)

Please be consistent with your namespace. Please use the dm9051_ prefix everywhere.

drivers/net/ethernet/davicom/dm9051.c line 122

Quoted 7 lines
drivers/net/ethernet/davicom/dm9051.c new file +7 -0
+{
+	int ret;
+
+	iow(db, DM9051_EPAR, DM9051_PHY | reg);
+	iow(db, DM9051_EPCR, EPCR_ERPRR | EPCR_EPOS);
+	while (ior(db, DM9051_EPCR) & EPCR_ERRE)
+		;

include/linux/iopoll.h No potentially endless loops please.

Quoted 5 lines
drivers/net/ethernet/davicom/dm9051.c new file +5 -0
+static unsigned int dm9051_chipid(struct device *dev, struct board_info *db)
+{
+	unsigned int chipid;
+
+	chipid = iior(dev, db, DM9051_PIDL);

drivers/net/ethernet/davicom/dm9051.c line 205

Quoted 10 lines
drivers/net/ethernet/davicom/dm9051.c new file +10 -0
+	chipid |= (unsigned int)iior(dev, db, DM9051_PIDH) << 8;
+	if (chipid == (DM9051_ID >> 16))
+		return chipid;
+	chipid = iior(dev, db, DM9051_PIDL);
+	chipid |= (unsigned int)iior(dev, db, DM9051_PIDH) << 8;
+	if (chipid == (DM9051_ID >> 16))
+		return chipid;
+	dev_info(dev, "Read [DM9051_PID] = %04x\n", chipid);
+	dev_info(dev, "Read [DM9051_PID] error!\n");
+	return 0;

If this is an error case, returning 0 is not a good idea. -ENODEV?

drivers/net/ethernet/davicom/dm9051.c line 213

Quoted 6 lines
drivers/net/ethernet/davicom/dm9051.c new file +6 -0
+static void dm9051_phy_advertise_pausecap_func(struct board_info *db)
+{
+	int phy4 = dm_phy_read_func(db, MII_ADVERTISE); //DBG_20140407
+
+	dm_phy_write_func(db, MII_ADVERTISE, phy4 | ADVERTISE_PAUSE_CAP); // dm95 flow-control RX!
+}

Use seem to be using the deprecated mii code. Please replace it with phylib. phylib will then do things like advertising.

drivers/net/ethernet/davicom/dm9051.c line 217

Quoted 3 lines
drivers/net/ethernet/davicom/dm9051.c new file +3 -0
+static void dm9051_reset(struct board_info *db)
+{
+	mdelay(2); //delay 2 ms any need before NCR_RST (20170510)

Since this is a new driver, there is no history. Comments like 20170510 don't add anything useful.

Quoted 1 line

+static void IMR_DISABLE_LOCK_ESSENTIAL(struct board_info *db)

Don't use upper case for functions.

Quoted 5 lines
drivers/net/ethernet/davicom/dm9051.c new file +5 -0
+{
+	ADDR_LOCK_HEAD_ESSENTIAL(db);
+	imr_reg_stop(db);
+	ADDR_LOCK_TAIL_ESSENTIAL(db);
+}

drivers/net/ethernet/davicom/dm9051.c line 256

Quoted 10 lines
drivers/net/ethernet/davicom/dm9051.c new file +9 -0
 
+static int dm9051_read_mac_to_dev(struct device *dev, struct net_device *ndev,
+				  struct board_info *db)
+{
+	int i;
+	u8 mac_fix[ETH_ALEN] = { 0x00, 0x60, 0x6e, 0x90, 0x51, 0xee };
+
+	for (i = 0; i < ETH_ALEN; i++)
+		ndev->dev_addr[i] = ior(db, DM9051_PAR + i);
+	if (!is_valid_ether_addr(ndev->dev_addr)) {

You should use a random MAC address. eth_hw_addr_random(ndev);

drivers/net/ethernet/davicom/dm9051.c line 262

Quoted 6 lines
drivers/net/ethernet/davicom/dm9051.c new file +6 -0
+		for (i = 0; i < ETH_ALEN; i++)
+			iow(db, DM9051_PAR + i, mac_fix[i]);
+		for (i = 0; i < ETH_ALEN; i++)
+			ndev->dev_addr[i] = ior(db, DM9051_PAR + i);
+		dev_info(dev, "dm9 [reg_netdev][%s][chip MAC: %pM (%s)]\n",
+			 ndev->name, ndev->dev_addr, "FIX-1");

dev_dbg() ?

drivers/net/ethernet/davicom/dm9051.c line 265

Quoted 3 lines
drivers/net/ethernet/davicom/dm9051.c new file +3 -0
+		return 0;
+	}
+	return 1;

If this is an error, please use an error code.

drivers/net/ethernet/davicom/dm9051.c line 331

Quoted 11 lines
drivers/net/ethernet/davicom/dm9051.c new file +11 -0
+static void dm_set_mac_lock(struct board_info *db)
+{
+	struct net_device *ndev = db->ndev;
+
+	if (db->enter_setmac) {
+		int i, oft;
+
+		db->enter_setmac = 0;
+		netdev_info(ndev, "set_mac_address %02x %02x %02x  %02x %02x %02x\n",
+			    ndev->dev_addr[0], ndev->dev_addr[1], ndev->dev_addr[2],
+			    ndev->dev_addr[3], ndev->dev_addr[4], ndev->dev_addr[5]);

netdev_dbg()

Also, %pM can be used here.

drivers/net/ethernet/davicom/dm9051.c line 362

Quoted 6 lines
drivers/net/ethernet/davicom/dm9051.c new file +6 -0
+static
+const struct net_device_ops dm9051_netdev_ops = {
+	.ndo_open = dm9051_open,
+	.ndo_stop = dm9051_stop,
+	.ndo_start_xmit = DM9051_START_XMIT,
+	.ndo_set_rx_mode = dm9051_set_multicast_list_schedule,

_schedule? This is called in a context you can make blocking calls. So i don't see why you need the work queue.

drivers/net/ethernet/davicom/dm9051.c line 375

Quoted 7 lines
drivers/net/ethernet/davicom/dm9051.c new file +7 -0
+static void dm9051_get_drvinfo(struct net_device *dev,
+			       struct ethtool_drvinfo *info)
+{
+	struct board_info *dm = to_dm9051_board(dev);
+
+	strscpy(info->driver, DRVNAME_9051, sizeof(info->driver));
+	strscpy(info->version, dm->DRV_VERSION, sizeof(info->version));

version is meaningless. Please leave it empty, and the core will fill it in with the kernel version.

drivers/net/ethernet/davicom/dm9051.c line 402

Quoted 4 lines
drivers/net/ethernet/davicom/dm9051.c new file +4 -0
+	strscpy(info->bus_info, dev_name(dev->dev.parent), sizeof(info->bus_info));
+}
+
+/* LNX_KERNEL_v58 */

58? We are only at version 5 at the moment?

Quoted 2 lines

+/* Tips: reset and increase the RST counter
+ */

Tips?

Quoted 15 lines
drivers/net/ethernet/davicom/dm9051.c new file +15 -0
+static void dm9051_fifo_reset(u8 state, u8 *hstr, struct board_info *db)
+{
+	db->bc.DO_FIFO_RST_counter++;
+	dm9051_reset(db);
+}
+
+static void dm9051_reset_dm9051(struct board_info *db, int rxlen)
+{
+	struct net_device *ndev = db->ndev;
+	char *sbuff = (char *)db->prxhdr;
+	char hstr[72];
+
+	netdev_info(ndev, "dm9-pkt-Wrong RxLen over-range (%x= %d > %x= %d)\n",
+		    rxlen, rxlen, DM9051_PKT_MAX, DM9051_PKT_MAX);
+

drivers/net/ethernet/davicom/dm9051.c line 516

Quoted 10 lines
drivers/net/ethernet/davicom/dm9051.c new file +10 -0
+	db->bc.large_err_counter++;
+	db->bc.mac_ovrsft_counter++; //increase the MAC over_shift counter
+	dm9051_fifo_reset(11, hstr, db);
+	sprintf(hstr, "dmfifo_reset( 11 RxLenErr ) rxhdr %02x %02x %02x %02x (quick)",
+		sbuff[0], sbuff[1], sbuff[2], sbuff[3]);
+	netdev_info(ndev, "%s\n", hstr);
+	netdev_info(ndev, "dm9 reset-done: of LargeRxLen\n");
+	netdev_info(ndev, " RxLenErr&MacOvrSft_Er %d, RST_c %d\n",
+		    db->bc.mac_ovrsft_counter,
+		    db->bc.DO_FIFO_RST_counter);

There is a lot of kernel log spamming going on here. Please either remove this, of use netdev_dbg(). Please look throught all the uses of _info() and see if they are actually useful, or should be removed.

drivers/net/ethernet/davicom/dm9051.c line 632

Quoted 2 lines
drivers/net/ethernet/davicom/dm9051.c new file +2 -0
+#define dm_msg_open_done(nd, maddr, irqn) \
+	netdev_info(nd, "[dm_open] %pM irq_no %d ACTIVE_LOW\n", maddr, irqn)

Please don't use macros like this.

Quoted 1 line

+#define init_sched_phy(db) schedule_delayed_work(&(db)->phy_poll, HZ * 1)

No, no, no.

This code feels like it is a vendor crap driver, with an abstraction over the OS. That is not how Linux drivers should work. If you need to lock a mutux, call the mutex_lock(), not a wrapper around mutex_lock. Please remove all these wrapper.

Andrew

maintainer
#7 lore raw
In reply to Joseph CHANG
Quoted 4 lines · On Fri, 3 Dec 2021 04:46:54 +0800 Joseph CHANG wrote:

*** DM9051 is a SPI interface ethernet controller chip *** *** For a embedded Linux device to construct an ethernet port *** *** Fewer CPU interface pins is its advantage comapre to DM9000 *** *** It need only cs / mosi / miso / clock and an interrupt pin ***

No need for the *** markings in the subject and message body.

Please make sure to fix the dates on the patches, they are two weeks in the future.