cndm: Add support for ethtool

Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
Alex Forencich
2025-12-31 23:58:10 -08:00
parent cc4e465462
commit ecf62c94e6
4 changed files with 34 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ cndm-y += cndm_main.o
cndm-y += cndm_devlink.o cndm-y += cndm_devlink.o
cndm-y += cndm_dev.o cndm-y += cndm_dev.o
cndm-y += cndm_netdev.o cndm-y += cndm_netdev.o
cndm-y += cndm_ethtool.o
cndm-y += cndm_tx.o cndm-y += cndm_tx.o
cndm-y += cndm_rx.o cndm-y += cndm_rx.o

View File

@@ -141,6 +141,9 @@ void cndm_destroy_netdev(struct net_device *ndev);
// cndm_dev.c // cndm_dev.c
extern const struct file_operations cndm_fops; extern const struct file_operations cndm_fops;
// cndm_ethtool.c
extern const struct ethtool_ops cndm_ethtool_ops;
// cndm_tx.c // cndm_tx.c
int cndm_free_tx_buf(struct cndm_priv *priv); int cndm_free_tx_buf(struct cndm_priv *priv);
int cndm_poll_tx_cq(struct napi_struct *napi, int budget); int cndm_poll_tx_cq(struct napi_struct *napi, int budget);

View File

@@ -0,0 +1,29 @@
// SPDX-License-Identifier: GPL
/*
Copyright (c) 2025 FPGA Ninja, LLC
Authors:
- Alex Forencich
*/
#include "cndm.h"
#include <linux/ethtool.h>
static void cndm_get_drvinfo(struct net_device *ndev,
struct ethtool_drvinfo *drvinfo)
{
struct cndm_priv *priv = netdev_priv(ndev);
struct cndm_dev *cdev = priv->cdev;
strscpy(drvinfo->driver, DRIVER_NAME, sizeof(drvinfo->driver));
strscpy(drvinfo->version, DRIVER_VERSION, sizeof(drvinfo->version));
snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "TODO"); // TODO
strscpy(drvinfo->bus_info, dev_name(cdev->dev), sizeof(drvinfo->bus_info));
}
const struct ethtool_ops cndm_ethtool_ops = {
.get_drvinfo = cndm_get_drvinfo,
};

View File

@@ -104,6 +104,7 @@ struct net_device *cndm_create_netdev(struct cndm_dev *cdev, int port, void __io
eth_hw_addr_random(ndev); eth_hw_addr_random(ndev);
ndev->netdev_ops = &cndm_netdev_ops; ndev->netdev_ops = &cndm_netdev_ops;
ndev->ethtool_ops = &cndm_ethtool_ops;
ndev->hw_features = 0; ndev->hw_features = 0;
ndev->features = 0; ndev->features = 0;