more eth_hw_addr_set ifdefs for suse's kernel

This commit is contained in:
Bjarne von Horn 2024-02-05 12:44:01 +00:00
parent 1485d78d6a
commit c76399b8db
9 changed files with 132 additions and 8 deletions

View File

@ -155,6 +155,17 @@
#include "../globals.h"
#include "ecdev.h"
#ifdef CONFIG_SUSE_KERNEL
#include <linux/suse_version.h>
#else
# ifndef SUSE_VERSION
# define SUSE_VERSION 0
# endif
# ifndef SUSE_PATCHLEVEL
# define SUSE_PATCHLEVEL 0
# endif
#endif
#define RTL8139_DRIVER_NAME DRV_NAME \
" EtherCAT-capable Fast Ethernet driver " \
DRV_VERSION ", master " EC_MASTER_VERSION
@ -2389,8 +2400,11 @@ static int rtl8139_set_mac_address(struct net_device *dev, void *p)
if (!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL;
#if SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 5
eth_hw_addr_set(dev, addr->sa_data);
#else
memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
#endif
spin_lock_irq(&tp->lock);
RTL_W8_F(Cfg9346, Cfg9346_Unlock);

View File

@ -2415,7 +2415,11 @@ static int e100_set_mac_address(struct net_device *netdev, void *p)
if (!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL;
#if SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 5
eth_hw_addr_set(netdev, addr->sa_data);
#else
memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
#endif
e100_exec_cb(nic, NULL, e100_setup_iaaddr);
return 0;
@ -3099,7 +3103,11 @@ static int e100_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
e100_phy_init(nic);
#if SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 5
eth_hw_addr_set(netdev, (const u8*)nic->eeprom);
#else
memcpy(netdev->dev_addr, nic->eeprom, ETH_ALEN);
#endif
if (!is_valid_ether_addr(netdev->dev_addr)) {
if (!eeprom_bad_csum_allow) {
netif_err(nic, probe, nic->netdev, "Invalid MAC address from EEPROM, aborting\n");

View File

@ -8,6 +8,17 @@
#include <linux/bitops.h>
#include <linux/if_vlan.h>
#ifdef CONFIG_SUSE_KERNEL
#include <linux/suse_version.h>
#else
# ifndef SUSE_VERSION
# define SUSE_VERSION 0
# endif
# ifndef SUSE_PATCHLEVEL
# define SUSE_PATCHLEVEL 0
# endif
#endif
char e1000_driver_name[] = "ec_e1000";
static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
@ -1137,7 +1148,11 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
e_err(probe, "EEPROM Read Error\n");
}
/* don't block initialization here due to bad MAC address */
#if SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 5
eth_hw_addr_set(netdev, hw->mac_addr);
#else
memcpy(netdev->dev_addr, hw->mac_addr, netdev->addr_len);
#endif
if (!is_valid_ether_addr(netdev->dev_addr))
e_err(probe, "Invalid MAC Address\n");
@ -2273,7 +2288,11 @@ static int e1000_set_mac(struct net_device *netdev, void *p)
if (hw->mac_type == e1000_82542_rev2_0)
e1000_enter_82542_rst(adapter);
#if SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 5
eth_hw_addr_set(netdev, addr->sa_data);
#else
memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
#endif
memcpy(hw->mac_addr, addr->sa_data, netdev->addr_len);
e1000_rar_set(hw, hw->mac_addr, 0);

View File

@ -29,6 +29,17 @@
#include "e1000-5.14-ethercat.h"
#ifdef CONFIG_SUSE_KERNEL
#include <linux/suse_version.h>
#else
# ifndef SUSE_VERSION
# define SUSE_VERSION 0
# endif
# ifndef SUSE_PATCHLEVEL
# define SUSE_PATCHLEVEL 0
# endif
#endif
char e1000e_driver_name[] = "ec_e1000e";
static inline int check_arbiter_wa_flag(const struct e1000_adapter *adapter)
@ -4887,7 +4898,11 @@ static int e1000_set_mac(struct net_device *netdev, void *p)
if (!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL;
#if SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 5
eth_hw_addr_set(netdev, addr->sa_data);
#else
memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
#endif
memcpy(adapter->hw.mac.addr, addr->sa_data, netdev->addr_len);
hw->mac.ops.rar_set(&adapter->hw, adapter->hw.mac.addr, 0);
@ -7705,7 +7720,11 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
dev_err(&pdev->dev,
"NVM Read Error while reading MAC address\n");
#if SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 5
eth_hw_addr_set(netdev, adapter->hw.mac.addr);
#else
memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len);
#endif
if (!is_valid_ether_addr(netdev->dev_addr)) {
dev_err(&pdev->dev, "Invalid MAC Address: %pM\n",

View File

@ -49,6 +49,17 @@
#define EC_GEN_RX_BUF_SIZE 1600
#ifdef CONFIG_SUSE_KERNEL
#include <linux/suse_version.h>
#else
# ifndef SUSE_VERSION
# define SUSE_VERSION 0
# endif
# ifndef SUSE_PATCHLEVEL
# define SUSE_PATCHLEVEL 0
# endif
#endif
/*****************************************************************************/
int __init ec_gen_init_module(void);
@ -255,7 +266,7 @@ int ec_gen_device_offer(
int ret = 0;
dev->used_netdev = desc->netdev;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) || (SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 5)
eth_hw_addr_set(dev->netdev, desc->dev_addr);
#else
memcpy(dev->netdev->dev_addr, desc->dev_addr, ETH_ALEN);

View File

@ -41,6 +41,18 @@
#include "bcmgenet-5.14-ethercat.h"
#ifdef CONFIG_SUSE_KERNEL
#include <linux/suse_version.h>
#else
# ifndef SUSE_VERSION
# define SUSE_VERSION 0
# endif
# ifndef SUSE_PATCHLEVEL
# define SUSE_PATCHLEVEL 0
# endif
#endif
/* Maximum number of hardware queues, downsized if needed */
#define GENET_MAX_MQ_CNT 4
@ -3323,7 +3335,7 @@ static void bcmgenet_umac_reset(struct bcmgenet_priv *priv)
}
static void bcmgenet_set_hw_addr(struct bcmgenet_priv *priv,
unsigned char *addr)
const unsigned char *addr)
{
bcmgenet_umac_writel(priv, get_unaligned_be32(&addr[0]), UMAC_MAC0);
bcmgenet_umac_writel(priv, get_unaligned_be16(&addr[4]), UMAC_MAC1);
@ -3621,7 +3633,7 @@ static void bcmgenet_timeout(struct net_device *dev, unsigned int txqueue)
#define MAX_MDF_FILTER 17
static inline void bcmgenet_set_mdf_addr(struct bcmgenet_priv *priv,
unsigned char *addr,
const unsigned char *addr,
int *i)
{
bcmgenet_umac_writel(priv, addr[0] << 8 | addr[1],
@ -3694,8 +3706,11 @@ static int bcmgenet_set_mac_addr(struct net_device *dev, void *p)
if (netif_running(dev))
return -EBUSY;
#if SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 5
eth_hw_addr_set(dev, addr->sa_data);
#else
ether_addr_copy(dev->dev_addr, addr->sa_data);
#endif
return 0;
}
@ -4140,11 +4155,25 @@ static int bcmgenet_probe(struct platform_device *pdev)
bcmgenet_power_up(priv, GENET_POWER_PASSIVE);
if (pd && !IS_ERR_OR_NULL(pd->mac_address))
#if SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 5
eth_hw_addr_set(dev, pd->mac_address);
#else
ether_addr_copy(dev->dev_addr, pd->mac_address);
#endif
else
#if SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 5
if (!device_get_ethdev_address(&pdev->dev, dev))
if (has_acpi_companion(&pdev->dev)) {
u8 addr[ETH_ALEN];
bcmgenet_get_hw_addr(priv, addr);
eth_hw_addr_set(dev, addr);
}
#else
if (!device_get_mac_address(&pdev->dev, dev->dev_addr, ETH_ALEN))
if (has_acpi_companion(&pdev->dev))
bcmgenet_get_hw_addr(priv, dev->dev_addr);
#endif
if (!is_valid_ether_addr(dev->dev_addr)) {
dev_warn(&pdev->dev, "using random Ethernet MAC\n");

View File

@ -3434,7 +3434,11 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
dev_err(&pdev->dev, "NVM Read Error\n");
}
#if SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 5
eth_hw_addr_set(netdev, hw->mac.addr);
#else
memcpy(netdev->dev_addr, hw->mac.addr, netdev->addr_len);
#endif
if (!is_valid_ether_addr(netdev->dev_addr)) {
dev_err(&pdev->dev, "Invalid MAC Address\n");
@ -5102,7 +5106,11 @@ static int igb_set_mac(struct net_device *netdev, void *p)
if (!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL;
#if SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 5
eth_hw_addr_set(netdev, addr->sa_data);
#else
memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
#endif
memcpy(hw->mac.addr, addr->sa_data, netdev->addr_len);
/* set the correct pool for the new PF MAC address in entry 0 */

View File

@ -5317,7 +5317,7 @@ static int rtl_get_ether_clk(struct rtl8169_private *tp)
static void rtl_init_mac_address(struct rtl8169_private *tp)
{
struct net_device *dev = tp->dev;
u8 *mac_addr = dev->dev_addr;
u8 mac_addr[ETH_ALEN];
int rc;
rc = eth_platform_get_mac_address(tp_to_dev(tp), mac_addr);
@ -5335,6 +5335,12 @@ static void rtl_init_mac_address(struct rtl8169_private *tp)
eth_hw_addr_random(dev);
dev_warn(tp_to_dev(tp), "can't read MAC address, setting random one\n");
done:
#if SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 5
eth_hw_addr_set(dev, mac_addr);
#else
memcpy(dev->dev_addr, mac_addr, sizeof(mac_addr));
#endif
rtl_rar_set(tp, mac_addr);
}

View File

@ -44,6 +44,16 @@
#include "mailbox.h"
#include "ethernet.h"
#ifdef CONFIG_SUSE_KERNEL
#include <linux/suse_version.h>
#else
# ifndef SUSE_VERSION
# define SUSE_VERSION 0
# endif
# ifndef SUSE_PATCHLEVEL
# define SUSE_PATCHLEVEL 0
# endif
#endif
/*****************************************************************************/
/** Defines the debug level of EoE processing.
@ -172,7 +182,7 @@ int ec_eoe_init(
eoe->dev->get_stats = ec_eoedev_stats;
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) || (SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 5)
eth_hw_addr_set(eoe->dev, mac_addr);
#else
memcpy(eoe->dev->dev_addr, mac_addr, sizeof(mac_addr));
@ -200,7 +210,7 @@ int ec_eoe_init(
// make the last address octet unique
mac_addr[ETH_ALEN - 1] = (uint8_t) eoe->dev->ifindex;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) || (SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 5)
eth_hw_addr_set(eoe->dev, mac_addr);
#else
memcpy(eoe->dev->dev_addr, mac_addr, sizeof(mac_addr));