pc_nic_drv: add R8169 driver

This commits enables the R8169 driver and was tested with two
RTL8168h/8111h (10ec:8168 rev 0x15 sub 1462:7a38 / 1d05:109f) and
two equal RTL8125B (10ec:8125 rev 0x5 sub 1458:e000) devices
running Sculpt.

Firmware loading is for now not implemented but specific Linux
commits suggest it could be necessary. However, doing so will be
post-poned until we have gathered more experience with the driver.

Restarting the driver might lead to the following IOMMU error
messages but the device seems to work anyway:

[ 0] IOMMU:0xffffffff817ec040 FR:0x8a00000000002500 FI:0xfffffffdf8d30000 type:0x8 BDF:25:00.0
[ 0] IOMMU:0xffffffff817ec040 FR:0x2000004200002500 FI:0x000c21b0 type:0x2 BDF:25:00.0
[ 0] IOMMU:0xffffffff817ec040 FR:0x2020004200002500 FI:0x000c21a0 type:0x2 BDF:25:00.0
[ 0] IOMMU:0xffffffff817ec040 FR:0x2020004200002500 FI:0x00138000 type:0x2 BDF:25:00.0
[…]
[ 0] IOMMU:0xffffffff817ec040 FR:0x8a00000000002500 FI:0xfffffffdf8d30000 type:0x8 BDF:25:00.0
[ 0] IOMMU:0xffffffff817ec040 FR:0x2020004300002500 FI:0x00124000 type:0x2 BDF:25:00.0

Issue #4921.
This commit is contained in:
Josef Söntgen 2023-06-21 06:42:49 +00:00 committed by Norman Feske
parent 1996041dcc
commit afaabb3121
7 changed files with 317 additions and 42 deletions

View File

@ -36,6 +36,10 @@ drivers/net/ethernet/intel/e1000e/manage.h
drivers/net/ethernet/intel/e1000e/nvm.h
drivers/net/ethernet/intel/e1000e/phy.h
drivers/net/ethernet/intel/e1000e/regs.h
drivers/net/ethernet/realtek/r8169.h
drivers/net/ethernet/realtek/r8169_firmware.h
drivers/net/phy/mdio-boardinfo.h
drivers/net/phy/swphy.h
include/asm-generic/asm-prototypes.h
include/asm-generic/bitops/fls64.h
include/asm-generic/div64.h
@ -60,6 +64,7 @@ include/linux/etherdevice.h
include/linux/ethtool_netlink.h
include/linux/filter.h
include/linux/firmware.h
include/linux/gpio/driver.h
include/linux/icmpv6.h
include/linux/if_arp.h
include/linux/if_macvlan.h
@ -69,23 +74,32 @@ include/linux/inet.h
include/linux/inetdevice.h
include/linux/ip.h
include/linux/ipv6_route.h
include/linux/irqchip/chained_irq.h
include/linux/kcov.h
include/linux/mpls.h
include/linux/netfilter.h
include/linux/netfilter_netdev.h
include/linux/netpoll.h
include/linux/nvmem-consumer.h
include/linux/of_gpio.h
include/linux/of_mdio.h
include/linux/of_net.h
include/linux/phy_fixed.h
include/linux/phy_led_triggers.h
include/linux/phylink.h
include/linux/pinctrl/pinconf-generic.h
include/linux/pinctrl/pinctrl.h
include/linux/platform_data/dsa.h
include/linux/pps_kernel.h
include/linux/proc_ns.h
include/linux/pse-pd/pse.h
include/linux/ptp_classify.h
include/linux/ptp_clock_kernel.h
include/linux/rcupdate_trace.h
include/linux/rhashtable.h
include/linux/sctp.h
include/linux/set_memory.h
include/linux/sfp.h
include/linux/skb_array.h
include/linux/sock_diag.h
include/linux/wireless.h
@ -134,6 +148,7 @@ include/net/xdp_sock_drv.h
include/net/xfrm.h
include/net/xsk_buff_pool.h
include/trace/events/fib.h
include/trace/events/mdio.h
include/trace/events/napi.h
include/trace/events/neigh.h
include/trace/events/net.h

View File

@ -35,6 +35,14 @@ int sysfs_add_file_to_group(struct kobject * kobj,const struct attribute * attr,
return 0;
}
#include <linux/sysfs.h>
int sysfs_create_link_nowarn(struct kobject * kobj,struct kobject * target,const char * name)
{
lx_emul_trace(__func__);
return 0;
}
#include <linux/proc_ns.h>
int proc_alloc_inum(unsigned int * inum)
@ -249,14 +257,6 @@ int pci_enable_device_mem(struct pci_dev *dev)
#include <linux/pci.h>
int pci_select_bars(struct pci_dev *dev, unsigned long flags)
{
lx_emul_trace(__func__);
return 0;
}
#include <linux/pci.h>
int pci_request_selected_regions(struct pci_dev *dev, int, const char *res_name)
{
lx_emul_trace(__func__);
@ -345,3 +345,48 @@ void pci_clear_master(struct pci_dev *dev)
{
lx_emul_trace(__func__);
}
#include <linux/pci.h>
int pcim_set_mwi(struct pci_dev * dev)
{
lx_emul_trace(__func__);
return 0;
}
#include <linux/iommu.h>
void iommu_device_unuse_default_domain(struct device * dev)
{
lx_emul_trace(__func__);
}
#include <linux/pci.h>
int pcim_iomap_regions(struct pci_dev * pdev,int mask,const char * name)
{
lx_emul_trace(__func__);
return 0;
}
#include <linux/firmware.h>
int request_firmware(const struct firmware ** firmware_p,const char * name,struct device * device)
{
lx_emul_trace(__func__);
return -1;
}
#include <linux/net.h>
int net_ratelimit(void)
{
lx_emul_trace(__func__);
/* suppress */
return 0;
}

View File

@ -12,6 +12,7 @@
*/
#include <lx_emul.h>
#include <lx_emul/io_mem.h>
unsigned long __FIXADDR_TOP = 0xfffff000;
@ -158,3 +159,81 @@ int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val)
printk("%s: unexpected read at %x\n", __func__, pos);
return -1;
}
static unsigned long *_pci_iomap_table;
void __iomem * const * pcim_iomap_table(struct pci_dev * pdev)
{
unsigned i;
if (!_pci_iomap_table)
_pci_iomap_table = kzalloc(sizeof (unsigned long*) * 6, GFP_KERNEL);
if (!_pci_iomap_table)
return NULL;
for (i = 0; i < 6; i++) {
struct resource *r = &pdev->resource[i];
unsigned long phys_addr = r->start;
unsigned long size = r->end - r->start;
if (!(r->flags & IORESOURCE_MEM))
continue;
if (!phys_addr || !size)
continue;
_pci_iomap_table[i] =
(unsigned long)lx_emul_io_mem_map(phys_addr, size);
}
return (void const *)_pci_iomap_table;
}
int pci_select_bars(struct pci_dev *dev, unsigned long flags)
{
int bars = 0;
unsigned long const *table;
unsigned i;
if (!(flags & IORESOURCE_MEM))
return 0;
/* misuse 'pcim_iomap_table()' for querying I/O mem */
table = (unsigned long const *)pcim_iomap_table(dev);
for (i = 0; i < 6; i++)
if (table[i])
bars |= (1 << i);
return bars;
}
int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
unsigned int max_vecs, unsigned int flags,
struct irq_affinity *aff_desc)
{
if ((flags & PCI_IRQ_LEGACY) && min_vecs == 1 && dev->irq)
return 1;
return -ENOSPC;
}
int pci_irq_vector(struct pci_dev *dev, unsigned int nr)
{
if (WARN_ON_ONCE(nr > 0))
return -EINVAL;
return dev->irq;
}
#include <linux/dma-mapping.h>
void *dmam_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
gfp_t gfp, unsigned long attrs)
{
return dma_alloc_attrs(dev, size, dma_handle, gfp, attrs);
}

View File

@ -1,7 +1,7 @@
/*
* \brief Dummy definitions of Linux Kernel functions
* \author Automatically generated file - do no edit
* \date 2023-06-05
* \date 2023-06-22
*/
#include <lx_emul.h>
@ -171,6 +171,11 @@ void bust_spinlocks(int yes)
}
#include <linux/bitrev.h>
u8 const byte_rev_table[256] = {};
#include <linux/console.h>
void console_flush_on_panic(enum con_flush_mode mode)
@ -211,6 +216,14 @@ void cpu_latency_qos_remove_request(struct pm_qos_request * req)
}
#include <linux/property.h>
int device_create_managed_software_node(struct device * dev,const struct property_entry * properties,const struct software_node * parent)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/netlink.h>
void do_trace_netlink_extack(const char * msg)
@ -243,6 +256,30 @@ void emergency_restart(void)
}
#include <linux/ethtool_netlink.h>
int ethnl_cable_test_alloc(struct phy_device * phydev,u8 cmd)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/ethtool_netlink.h>
void ethnl_cable_test_finished(struct phy_device * phydev)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/ethtool_netlink.h>
void ethnl_cable_test_free(struct phy_device * phydev)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/ethtool.h>
void ethtool_convert_legacy_u32_to_link_mode(unsigned long * dst,u32 legacy_u32)
@ -410,14 +447,6 @@ long __sched io_schedule_timeout(long timeout)
struct io_tlb_mem io_tlb_default_mem;
#include <linux/iommu.h>
void iommu_device_unuse_default_domain(struct device * dev)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/irq_work.h>
void irq_work_tick(void)
@ -540,14 +569,6 @@ int mii_nway_restart(struct mii_if_info * mii)
}
#include <linux/net.h>
int net_ratelimit(void)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/netlink.h>
bool netlink_strict_get_check(struct sk_buff * skb)
@ -619,6 +640,14 @@ int pci_set_power_state(struct pci_dev * dev,pci_power_t state)
}
#include <linux/pci.h>
int pci_status_get_and_clear_errors(struct pci_dev * pdev)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/pci.h>
int pci_wake_from_d3(struct pci_dev * dev,bool enable)
@ -627,6 +656,14 @@ int pci_wake_from_d3(struct pci_dev * dev,bool enable)
}
#include <linux/pci.h>
int pci_write_config_byte(const struct pci_dev * dev,int where,u8 val)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/pci.h>
int pcie_capability_clear_and_set_word(struct pci_dev * dev,int pos,u16 clear,u16 set)
@ -643,6 +680,14 @@ int pcie_capability_write_word(struct pci_dev * dev,int pos,u16 val)
}
#include <linux/pci.h>
int pcie_set_readrq(struct pci_dev * dev,int rq)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/pci.h>
int pcix_get_mmrbc(struct pci_dev * dev)
@ -704,6 +749,14 @@ void proc_free_inum(unsigned int inum)
enum reboot_mode reboot_mode;
#include <linux/firmware.h>
void release_firmware(const struct firmware * fw)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/rhashtable.h>
struct rhash_lock_head __rcu ** rht_bucket_nested(const struct bucket_table * tbl,unsigned int hash)

View File

@ -25,6 +25,21 @@ drivers/net/ethernet/intel/e1000e/nvm.c
drivers/net/ethernet/intel/e1000e/param.c
drivers/net/ethernet/intel/e1000e/phy.c
drivers/net/ethernet/intel/e1000e/ptp.c
drivers/net/ethernet/realtek/r8169_firmware.c
drivers/net/ethernet/realtek/r8169_main.c
drivers/net/ethernet/realtek/r8169_phy_config.c
drivers/net/phy/fixed_phy.c
drivers/net/phy/linkmode.c
drivers/net/phy/mdio-boardinfo.c
drivers/net/phy/mdio_bus.c
drivers/net/phy/mdio_device.c
drivers/net/phy/mdio_devres.c
drivers/net/phy/phy-c45.c
drivers/net/phy/phy-core.c
drivers/net/phy/phy.c
drivers/net/phy/phy_device.c
drivers/net/phy/realtek.c
drivers/net/phy/swphy.c
drivers/pci/pci-driver.c
kernel/irq/chip.c
kernel/irq/devres.c

View File

@ -1,7 +1,7 @@
/*
* \brief Dummy definitions of Linux Kernel functions
* \author Automatically generated file - do no edit
* \date 2023-06-06
* \date 2023-06-21
*/
#include <lx_emul.h>
@ -171,6 +171,11 @@ void bust_spinlocks(int yes)
}
#include <linux/bitrev.h>
u8 const byte_rev_table[256] = {};
#include <linux/console.h>
void console_flush_on_panic(enum con_flush_mode mode)
@ -219,6 +224,14 @@ __sum16 csum_ipv6_magic(const struct in6_addr * saddr,const struct in6_addr * da
}
#include <linux/property.h>
int device_create_managed_software_node(struct device * dev,const struct property_entry * properties,const struct software_node * parent)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/netlink.h>
void do_trace_netlink_extack(const char * msg)
@ -251,6 +264,30 @@ void emergency_restart(void)
}
#include <linux/ethtool_netlink.h>
int ethnl_cable_test_alloc(struct phy_device * phydev,u8 cmd)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/ethtool_netlink.h>
void ethnl_cable_test_finished(struct phy_device * phydev)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/ethtool_netlink.h>
void ethnl_cable_test_free(struct phy_device * phydev)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/ethtool.h>
void ethtool_convert_legacy_u32_to_link_mode(unsigned long * dst,u32 legacy_u32)
@ -413,14 +450,6 @@ long __sched io_schedule_timeout(long timeout)
struct io_tlb_mem io_tlb_default_mem;
#include <linux/iommu.h>
void iommu_device_unuse_default_domain(struct device * dev)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/irq_work.h>
void irq_work_tick(void)
@ -543,14 +572,6 @@ int mii_nway_restart(struct mii_if_info * mii)
}
#include <linux/net.h>
int net_ratelimit(void)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/netlink.h>
bool netlink_strict_get_check(struct sk_buff * skb)
@ -622,6 +643,14 @@ int pci_set_power_state(struct pci_dev * dev,pci_power_t state)
}
#include <linux/pci.h>
int pci_status_get_and_clear_errors(struct pci_dev * pdev)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/pci.h>
int pci_wake_from_d3(struct pci_dev * dev,bool enable)
@ -630,6 +659,14 @@ int pci_wake_from_d3(struct pci_dev * dev,bool enable)
}
#include <linux/pci.h>
int pci_write_config_byte(const struct pci_dev * dev,int where,u8 val)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/pci.h>
int pcie_capability_clear_and_set_word(struct pci_dev * dev,int pos,u16 clear,u16 set)
@ -646,6 +683,14 @@ int pcie_capability_write_word(struct pci_dev * dev,int pos,u16 val)
}
#include <linux/pci.h>
int pcie_set_readrq(struct pci_dev * dev,int rq)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/pci.h>
int pcix_get_mmrbc(struct pci_dev * dev)
@ -707,6 +752,14 @@ void proc_free_inum(unsigned int inum)
enum reboot_mode reboot_mode;
#include <linux/firmware.h>
void release_firmware(const struct firmware * fw)
{
lx_emul_trace_and_stop(__func__);
}
#include <linux/rhashtable.h>
struct rhash_lock_head __rcu ** rht_bucket_nested(const struct bucket_table * tbl,unsigned int hash)

View File

@ -28,6 +28,21 @@ drivers/net/ethernet/intel/e1000e/nvm.c
drivers/net/ethernet/intel/e1000e/param.c
drivers/net/ethernet/intel/e1000e/phy.c
drivers/net/ethernet/intel/e1000e/ptp.c
drivers/net/ethernet/realtek/r8169_firmware.c
drivers/net/ethernet/realtek/r8169_main.c
drivers/net/ethernet/realtek/r8169_phy_config.c
drivers/net/phy/fixed_phy.c
drivers/net/phy/linkmode.c
drivers/net/phy/mdio-boardinfo.c
drivers/net/phy/mdio_bus.c
drivers/net/phy/mdio_device.c
drivers/net/phy/mdio_devres.c
drivers/net/phy/phy-c45.c
drivers/net/phy/phy-core.c
drivers/net/phy/phy.c
drivers/net/phy/phy_device.c
drivers/net/phy/realtek.c
drivers/net/phy/swphy.c
drivers/pci/pci-driver.c
kernel/irq/chip.c
kernel/irq/devres.c