Commit 6a3c910c authored by Joe Perches's avatar Joe Perches Committed by David S. Miller

ethernet: Convert MAC_ADDR_LEN uses to ETH_ALEN

Reduce the number of #defines, use the normal #define from if_ether.h
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 28011cf1
...@@ -734,7 +734,7 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) ...@@ -734,7 +734,7 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
mac_addr = of_get_mac_address(np); mac_addr = of_get_mac_address(np);
if (mac_addr) if (mac_addr)
memcpy(dev->dev_addr, mac_addr, MAC_ADDR_LEN); memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
if (model && !strcasecmp(model, "TSEC")) if (model && !strcasecmp(model, "TSEC"))
priv->device_flags = priv->device_flags =
...@@ -3114,7 +3114,7 @@ static void gfar_set_multi(struct net_device *dev) ...@@ -3114,7 +3114,7 @@ static void gfar_set_multi(struct net_device *dev)
static void gfar_clear_exact_match(struct net_device *dev) static void gfar_clear_exact_match(struct net_device *dev)
{ {
int idx; int idx;
static const u8 zero_arr[MAC_ADDR_LEN] = {0, 0, 0, 0, 0, 0}; static const u8 zero_arr[ETH_ALEN] = {0, 0, 0, 0, 0, 0};
for(idx = 1;idx < GFAR_EM_NUM + 1;idx++) for(idx = 1;idx < GFAR_EM_NUM + 1;idx++)
gfar_set_mac_for_addr(dev, idx, zero_arr); gfar_set_mac_for_addr(dev, idx, zero_arr);
...@@ -3137,7 +3137,7 @@ static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr) ...@@ -3137,7 +3137,7 @@ static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr)
{ {
u32 tempval; u32 tempval;
struct gfar_private *priv = netdev_priv(dev); struct gfar_private *priv = netdev_priv(dev);
u32 result = ether_crc(MAC_ADDR_LEN, addr); u32 result = ether_crc(ETH_ALEN, addr);
int width = priv->hash_width; int width = priv->hash_width;
u8 whichbit = (result >> (32 - width)) & 0x1f; u8 whichbit = (result >> (32 - width)) & 0x1f;
u8 whichreg = result >> (32 - width + 5); u8 whichreg = result >> (32 - width + 5);
...@@ -3158,7 +3158,7 @@ static void gfar_set_mac_for_addr(struct net_device *dev, int num, ...@@ -3158,7 +3158,7 @@ static void gfar_set_mac_for_addr(struct net_device *dev, int num,
struct gfar_private *priv = netdev_priv(dev); struct gfar_private *priv = netdev_priv(dev);
struct gfar __iomem *regs = priv->gfargrp[0].regs; struct gfar __iomem *regs = priv->gfargrp[0].regs;
int idx; int idx;
char tmpbuf[MAC_ADDR_LEN]; char tmpbuf[ETH_ALEN];
u32 tempval; u32 tempval;
u32 __iomem *macptr = &regs->macstnaddr1; u32 __iomem *macptr = &regs->macstnaddr1;
...@@ -3166,8 +3166,8 @@ static void gfar_set_mac_for_addr(struct net_device *dev, int num, ...@@ -3166,8 +3166,8 @@ static void gfar_set_mac_for_addr(struct net_device *dev, int num,
/* Now copy it into the mac registers backwards, cuz */ /* Now copy it into the mac registers backwards, cuz */
/* little endian is silly */ /* little endian is silly */
for (idx = 0; idx < MAC_ADDR_LEN; idx++) for (idx = 0; idx < ETH_ALEN; idx++)
tmpbuf[MAC_ADDR_LEN - 1 - idx] = addr[idx]; tmpbuf[ETH_ALEN - 1 - idx] = addr[idx];
gfar_write(macptr, *((u32 *) (tmpbuf))); gfar_write(macptr, *((u32 *) (tmpbuf)));
......
...@@ -74,9 +74,6 @@ struct ethtool_rx_list { ...@@ -74,9 +74,6 @@ struct ethtool_rx_list {
* will be the next highest multiple of 512 bytes. */ * will be the next highest multiple of 512 bytes. */
#define INCREMENTAL_BUFFER_SIZE 512 #define INCREMENTAL_BUFFER_SIZE 512
#define MAC_ADDR_LEN 6
#define PHY_INIT_TIMEOUT 100000 #define PHY_INIT_TIMEOUT 100000
#define GFAR_PHY_CHANGE_TIME 2 #define GFAR_PHY_CHANGE_TIME 2
......
...@@ -743,8 +743,7 @@ ...@@ -743,8 +743,7 @@
/* Change default LED mode. */ /* Change default LED mode. */
#define SET_DEFAULT_LED LED_SPEED_DUPLEX_ACT #define SET_DEFAULT_LED LED_SPEED_DUPLEX_ACT
#define MAC_ADDR_LEN 6 #define MAC_ADDR_ORDER(i) (ETH_ALEN - 1 - (i))
#define MAC_ADDR_ORDER(i) (MAC_ADDR_LEN - 1 - (i))
#define MAX_ETHERNET_BODY_SIZE 1500 #define MAX_ETHERNET_BODY_SIZE 1500
#define ETHERNET_HEADER_SIZE 14 #define ETHERNET_HEADER_SIZE 14
...@@ -1043,7 +1042,7 @@ enum { ...@@ -1043,7 +1042,7 @@ enum {
* @valid: Valid setting indicating the entry is being used. * @valid: Valid setting indicating the entry is being used.
*/ */
struct ksz_mac_table { struct ksz_mac_table {
u8 mac_addr[MAC_ADDR_LEN]; u8 mac_addr[ETH_ALEN];
u16 vid; u16 vid;
u8 fid; u8 fid;
u8 ports; u8 ports;
...@@ -1187,8 +1186,8 @@ struct ksz_switch { ...@@ -1187,8 +1186,8 @@ struct ksz_switch {
u8 diffserv[DIFFSERV_ENTRIES]; u8 diffserv[DIFFSERV_ENTRIES];
u8 p_802_1p[PRIO_802_1P_ENTRIES]; u8 p_802_1p[PRIO_802_1P_ENTRIES];
u8 br_addr[MAC_ADDR_LEN]; u8 br_addr[ETH_ALEN];
u8 other_addr[MAC_ADDR_LEN]; u8 other_addr[ETH_ALEN];
u8 broad_per; u8 broad_per;
u8 member; u8 member;
...@@ -1292,14 +1291,14 @@ struct ksz_hw { ...@@ -1292,14 +1291,14 @@ struct ksz_hw {
int tx_int_mask; int tx_int_mask;
int tx_size; int tx_size;
u8 perm_addr[MAC_ADDR_LEN]; u8 perm_addr[ETH_ALEN];
u8 override_addr[MAC_ADDR_LEN]; u8 override_addr[ETH_ALEN];
u8 address[ADDITIONAL_ENTRIES][MAC_ADDR_LEN]; u8 address[ADDITIONAL_ENTRIES][ETH_ALEN];
u8 addr_list_size; u8 addr_list_size;
u8 mac_override; u8 mac_override;
u8 promiscuous; u8 promiscuous;
u8 all_multi; u8 all_multi;
u8 multi_list[MAX_MULTICAST_LIST][MAC_ADDR_LEN]; u8 multi_list[MAX_MULTICAST_LIST][ETH_ALEN];
u8 multi_bits[HW_MULTICAST_SIZE]; u8 multi_bits[HW_MULTICAST_SIZE];
u8 multi_list_size; u8 multi_list_size;
...@@ -3654,7 +3653,7 @@ static void hw_add_wol_bcast(struct ksz_hw *hw) ...@@ -3654,7 +3653,7 @@ static void hw_add_wol_bcast(struct ksz_hw *hw)
static const u8 mask[] = { 0x3F }; static const u8 mask[] = { 0x3F };
static const u8 pattern[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; static const u8 pattern[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
hw_set_wol_frame(hw, 2, 1, mask, MAC_ADDR_LEN, pattern); hw_set_wol_frame(hw, 2, 1, mask, ETH_ALEN, pattern);
} }
/** /**
...@@ -3689,7 +3688,7 @@ static void hw_add_wol_ucast(struct ksz_hw *hw) ...@@ -3689,7 +3688,7 @@ static void hw_add_wol_ucast(struct ksz_hw *hw)
{ {
static const u8 mask[] = { 0x3F }; static const u8 mask[] = { 0x3F };
hw_set_wol_frame(hw, 0, 1, mask, MAC_ADDR_LEN, hw->override_addr); hw_set_wol_frame(hw, 0, 1, mask, ETH_ALEN, hw->override_addr);
} }
/** /**
...@@ -4055,7 +4054,7 @@ static void hw_set_addr(struct ksz_hw *hw) ...@@ -4055,7 +4054,7 @@ static void hw_set_addr(struct ksz_hw *hw)
{ {
int i; int i;
for (i = 0; i < MAC_ADDR_LEN; i++) for (i = 0; i < ETH_ALEN; i++)
writeb(hw->override_addr[MAC_ADDR_ORDER(i)], writeb(hw->override_addr[MAC_ADDR_ORDER(i)],
hw->io + KS884X_ADDR_0_OFFSET + i); hw->io + KS884X_ADDR_0_OFFSET + i);
...@@ -4072,17 +4071,16 @@ static void hw_read_addr(struct ksz_hw *hw) ...@@ -4072,17 +4071,16 @@ static void hw_read_addr(struct ksz_hw *hw)
{ {
int i; int i;
for (i = 0; i < MAC_ADDR_LEN; i++) for (i = 0; i < ETH_ALEN; i++)
hw->perm_addr[MAC_ADDR_ORDER(i)] = readb(hw->io + hw->perm_addr[MAC_ADDR_ORDER(i)] = readb(hw->io +
KS884X_ADDR_0_OFFSET + i); KS884X_ADDR_0_OFFSET + i);
if (!hw->mac_override) { if (!hw->mac_override) {
memcpy(hw->override_addr, hw->perm_addr, MAC_ADDR_LEN); memcpy(hw->override_addr, hw->perm_addr, ETH_ALEN);
if (empty_addr(hw->override_addr)) { if (empty_addr(hw->override_addr)) {
memcpy(hw->perm_addr, DEFAULT_MAC_ADDRESS, memcpy(hw->perm_addr, DEFAULT_MAC_ADDRESS, ETH_ALEN);
MAC_ADDR_LEN);
memcpy(hw->override_addr, DEFAULT_MAC_ADDRESS, memcpy(hw->override_addr, DEFAULT_MAC_ADDRESS,
MAC_ADDR_LEN); ETH_ALEN);
hw->override_addr[5] += hw->id; hw->override_addr[5] += hw->id;
hw_set_addr(hw); hw_set_addr(hw);
} }
...@@ -4130,16 +4128,16 @@ static int hw_add_addr(struct ksz_hw *hw, u8 *mac_addr) ...@@ -4130,16 +4128,16 @@ static int hw_add_addr(struct ksz_hw *hw, u8 *mac_addr)
int i; int i;
int j = ADDITIONAL_ENTRIES; int j = ADDITIONAL_ENTRIES;
if (!memcmp(hw->override_addr, mac_addr, MAC_ADDR_LEN)) if (!memcmp(hw->override_addr, mac_addr, ETH_ALEN))
return 0; return 0;
for (i = 0; i < hw->addr_list_size; i++) { for (i = 0; i < hw->addr_list_size; i++) {
if (!memcmp(hw->address[i], mac_addr, MAC_ADDR_LEN)) if (!memcmp(hw->address[i], mac_addr, ETH_ALEN))
return 0; return 0;
if (ADDITIONAL_ENTRIES == j && empty_addr(hw->address[i])) if (ADDITIONAL_ENTRIES == j && empty_addr(hw->address[i]))
j = i; j = i;
} }
if (j < ADDITIONAL_ENTRIES) { if (j < ADDITIONAL_ENTRIES) {
memcpy(hw->address[j], mac_addr, MAC_ADDR_LEN); memcpy(hw->address[j], mac_addr, ETH_ALEN);
hw_ena_add_addr(hw, j, hw->address[j]); hw_ena_add_addr(hw, j, hw->address[j]);
return 0; return 0;
} }
...@@ -4151,8 +4149,8 @@ static int hw_del_addr(struct ksz_hw *hw, u8 *mac_addr) ...@@ -4151,8 +4149,8 @@ static int hw_del_addr(struct ksz_hw *hw, u8 *mac_addr)
int i; int i;
for (i = 0; i < hw->addr_list_size; i++) { for (i = 0; i < hw->addr_list_size; i++) {
if (!memcmp(hw->address[i], mac_addr, MAC_ADDR_LEN)) { if (!memcmp(hw->address[i], mac_addr, ETH_ALEN)) {
memset(hw->address[i], 0, MAC_ADDR_LEN); memset(hw->address[i], 0, ETH_ALEN);
writel(0, hw->io + ADD_ADDR_INCR * i + writel(0, hw->io + ADD_ADDR_INCR * i +
KS_ADD_ADDR_0_HI); KS_ADD_ADDR_0_HI);
return 0; return 0;
...@@ -5676,7 +5674,7 @@ static int netdev_set_mac_address(struct net_device *dev, void *addr) ...@@ -5676,7 +5674,7 @@ static int netdev_set_mac_address(struct net_device *dev, void *addr)
hw_del_addr(hw, dev->dev_addr); hw_del_addr(hw, dev->dev_addr);
else { else {
hw->mac_override = 1; hw->mac_override = 1;
memcpy(hw->override_addr, mac->sa_data, MAC_ADDR_LEN); memcpy(hw->override_addr, mac->sa_data, ETH_ALEN);
} }
memcpy(dev->dev_addr, mac->sa_data, MAX_ADDR_LEN); memcpy(dev->dev_addr, mac->sa_data, MAX_ADDR_LEN);
...@@ -5786,7 +5784,7 @@ static void netdev_set_rx_mode(struct net_device *dev) ...@@ -5786,7 +5784,7 @@ static void netdev_set_rx_mode(struct net_device *dev)
netdev_for_each_mc_addr(ha, dev) { netdev_for_each_mc_addr(ha, dev) {
if (i >= MAX_MULTICAST_LIST) if (i >= MAX_MULTICAST_LIST)
break; break;
memcpy(hw->multi_list[i++], ha->addr, MAC_ADDR_LEN); memcpy(hw->multi_list[i++], ha->addr, ETH_ALEN);
} }
hw->multi_list_size = (u8) i; hw->multi_list_size = (u8) i;
hw_set_grp_addr(hw); hw_set_grp_addr(hw);
...@@ -6862,7 +6860,7 @@ static void get_mac_addr(struct dev_info *hw_priv, u8 *macaddr, int port) ...@@ -6862,7 +6860,7 @@ static void get_mac_addr(struct dev_info *hw_priv, u8 *macaddr, int port)
int num; int num;
i = j = num = got_num = 0; i = j = num = got_num = 0;
while (j < MAC_ADDR_LEN) { while (j < ETH_ALEN) {
if (macaddr[i]) { if (macaddr[i]) {
int digit; int digit;
...@@ -6893,7 +6891,7 @@ static void get_mac_addr(struct dev_info *hw_priv, u8 *macaddr, int port) ...@@ -6893,7 +6891,7 @@ static void get_mac_addr(struct dev_info *hw_priv, u8 *macaddr, int port)
} }
i++; i++;
} }
if (MAC_ADDR_LEN == j) { if (ETH_ALEN == j) {
if (MAIN_PORT == port) if (MAIN_PORT == port)
hw_priv->hw.mac_override = 1; hw_priv->hw.mac_override = 1;
} }
...@@ -7060,7 +7058,7 @@ static int __devinit pcidev_init(struct pci_dev *pdev, ...@@ -7060,7 +7058,7 @@ static int __devinit pcidev_init(struct pci_dev *pdev,
/* Multiple device interfaces mode requires a second MAC address. */ /* Multiple device interfaces mode requires a second MAC address. */
if (hw->dev_count > 1) { if (hw->dev_count > 1) {
memcpy(sw->other_addr, hw->override_addr, MAC_ADDR_LEN); memcpy(sw->other_addr, hw->override_addr, ETH_ALEN);
read_other_addr(hw); read_other_addr(hw);
if (mac1addr[0] != ':') if (mac1addr[0] != ':')
get_mac_addr(hw_priv, mac1addr, OTHER_PORT); get_mac_addr(hw_priv, mac1addr, OTHER_PORT);
...@@ -7110,12 +7108,11 @@ static int __devinit pcidev_init(struct pci_dev *pdev, ...@@ -7110,12 +7108,11 @@ static int __devinit pcidev_init(struct pci_dev *pdev,
dev->irq = pdev->irq; dev->irq = pdev->irq;
if (MAIN_PORT == i) if (MAIN_PORT == i)
memcpy(dev->dev_addr, hw_priv->hw.override_addr, memcpy(dev->dev_addr, hw_priv->hw.override_addr,
MAC_ADDR_LEN); ETH_ALEN);
else { else {
memcpy(dev->dev_addr, sw->other_addr, memcpy(dev->dev_addr, sw->other_addr, ETH_ALEN);
MAC_ADDR_LEN);
if (!memcmp(sw->other_addr, hw->override_addr, if (!memcmp(sw->other_addr, hw->override_addr,
MAC_ADDR_LEN)) ETH_ALEN))
dev->dev_addr[5] += port->first_port; dev->dev_addr[5] += port->first_port;
} }
......
...@@ -69,9 +69,6 @@ ...@@ -69,9 +69,6 @@
The RTL chips use a 64 element hash table based on the Ethernet CRC. */ The RTL chips use a 64 element hash table based on the Ethernet CRC. */
static const int multicast_filter_limit = 32; static const int multicast_filter_limit = 32;
/* MAC address length */
#define MAC_ADDR_LEN 6
#define MAX_READ_REQUEST_SHIFT 12 #define MAX_READ_REQUEST_SHIFT 12
#define TX_DMA_BURST 6 /* Maximum PCI burst, '6' is 1024 */ #define TX_DMA_BURST 6 /* Maximum PCI burst, '6' is 1024 */
#define SafeMtu 0x1c20 /* ... actually life sucks beyond ~7k */ #define SafeMtu 0x1c20 /* ... actually life sucks beyond ~7k */
...@@ -4101,7 +4098,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -4101,7 +4098,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
spin_lock_init(&tp->lock); spin_lock_init(&tp->lock);
/* Get MAC address */ /* Get MAC address */
for (i = 0; i < MAC_ADDR_LEN; i++) for (i = 0; i < ETH_ALEN; i++)
dev->dev_addr[i] = RTL_R8(MAC0 + i); dev->dev_addr[i] = RTL_R8(MAC0 + i);
memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
......
...@@ -47,8 +47,6 @@ ...@@ -47,8 +47,6 @@
#define sis190_rx_skb netif_rx #define sis190_rx_skb netif_rx
#define sis190_rx_quota(count, quota) count #define sis190_rx_quota(count, quota) count
#define MAC_ADDR_LEN 6
#define NUM_TX_DESC 64 /* [8..1024] */ #define NUM_TX_DESC 64 /* [8..1024] */
#define NUM_RX_DESC 64 /* [8..8192] */ #define NUM_RX_DESC 64 /* [8..8192] */
#define TX_RING_BYTES (NUM_TX_DESC * sizeof(struct TxDesc)) #define TX_RING_BYTES (NUM_TX_DESC * sizeof(struct TxDesc))
...@@ -1601,7 +1599,7 @@ static int __devinit sis190_get_mac_addr_from_eeprom(struct pci_dev *pdev, ...@@ -1601,7 +1599,7 @@ static int __devinit sis190_get_mac_addr_from_eeprom(struct pci_dev *pdev,
} }
/* Get MAC address from EEPROM */ /* Get MAC address from EEPROM */
for (i = 0; i < MAC_ADDR_LEN / 2; i++) { for (i = 0; i < ETH_ALEN / 2; i++) {
u16 w = sis190_read_eeprom(ioaddr, EEPROMMACAddr + i); u16 w = sis190_read_eeprom(ioaddr, EEPROMMACAddr + i);
((__le16 *)dev->dev_addr)[i] = cpu_to_le16(w); ((__le16 *)dev->dev_addr)[i] = cpu_to_le16(w);
...@@ -1653,7 +1651,7 @@ static int __devinit sis190_get_mac_addr_from_apc(struct pci_dev *pdev, ...@@ -1653,7 +1651,7 @@ static int __devinit sis190_get_mac_addr_from_apc(struct pci_dev *pdev,
udelay(50); udelay(50);
pci_read_config_byte(isa_bridge, 0x48, &reg); pci_read_config_byte(isa_bridge, 0x48, &reg);
for (i = 0; i < MAC_ADDR_LEN; i++) { for (i = 0; i < ETH_ALEN; i++) {
outb(0x9 + i, 0x78); outb(0x9 + i, 0x78);
dev->dev_addr[i] = inb(0x79); dev->dev_addr[i] = inb(0x79);
} }
...@@ -1692,7 +1690,7 @@ static inline void sis190_init_rxfilter(struct net_device *dev) ...@@ -1692,7 +1690,7 @@ static inline void sis190_init_rxfilter(struct net_device *dev)
*/ */
SIS_W16(RxMacControl, ctl & ~0x0f00); SIS_W16(RxMacControl, ctl & ~0x0f00);
for (i = 0; i < MAC_ADDR_LEN; i++) for (i = 0; i < ETH_ALEN; i++)
SIS_W8(RxMacAddr + i, dev->dev_addr[i]); SIS_W8(RxMacAddr + i, dev->dev_addr[i]);
SIS_W16(RxMacControl, ctl); SIS_W16(RxMacControl, ctl);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment