Commit 2bd01c5d authored by Roland Dreier's avatar Roland Dreier

RDMA/nes: Use print_mac() to format ethernet addresses for printing

Removing open-coded MAC formats shrinks the source and the generated
code too, eg on x86-64:

add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-103 (-103)
function                                     old     new   delta
make_cm_node                                 932     912     -20
nes_netdev_set_mac_address                   427     406     -21
nes_netdev_set_multicast_list               1148    1124     -24
nes_probe                                   2349    2311     -38
Acked-by: default avatarGlenn Streiff <gstreiff@neteffect.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 80750147
...@@ -353,13 +353,11 @@ struct ib_qp *nes_get_qp(struct ib_device *device, int qpn) ...@@ -353,13 +353,11 @@ struct ib_qp *nes_get_qp(struct ib_device *device, int qpn)
*/ */
static void nes_print_macaddr(struct net_device *netdev) static void nes_print_macaddr(struct net_device *netdev)
{ {
nes_debug(NES_DBG_INIT, "%s: MAC %02X:%02X:%02X:%02X:%02X:%02X, IRQ %u\n", DECLARE_MAC_BUF(mac);
netdev->name,
netdev->dev_addr[0], netdev->dev_addr[1], netdev->dev_addr[2],
netdev->dev_addr[3], netdev->dev_addr[4], netdev->dev_addr[5],
netdev->irq);
}
nes_debug(NES_DBG_INIT, "%s: %s, IRQ %u\n",
netdev->name, print_mac(mac, netdev->dev_addr), netdev->irq);
}
/** /**
* nes_interrupt - handle interrupts * nes_interrupt - handle interrupts
......
...@@ -1054,6 +1054,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core, ...@@ -1054,6 +1054,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
int arpindex = 0; int arpindex = 0;
struct nes_device *nesdev; struct nes_device *nesdev;
struct nes_adapter *nesadapter; struct nes_adapter *nesadapter;
DECLARE_MAC_BUF(mac);
/* create an hte and cm_node for this instance */ /* create an hte and cm_node for this instance */
cm_node = kzalloc(sizeof(*cm_node), GFP_ATOMIC); cm_node = kzalloc(sizeof(*cm_node), GFP_ATOMIC);
...@@ -1116,11 +1117,8 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core, ...@@ -1116,11 +1117,8 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
/* copy the mac addr to node context */ /* copy the mac addr to node context */
memcpy(cm_node->rem_mac, nesadapter->arp_table[arpindex].mac_addr, ETH_ALEN); memcpy(cm_node->rem_mac, nesadapter->arp_table[arpindex].mac_addr, ETH_ALEN);
nes_debug(NES_DBG_CM, "Remote mac addr from arp table:%02x," nes_debug(NES_DBG_CM, "Remote mac addr from arp table: %s\n",
" %02x, %02x, %02x, %02x, %02x\n", print_mac(mac, cm_node->rem_mac));
cm_node->rem_mac[0], cm_node->rem_mac[1],
cm_node->rem_mac[2], cm_node->rem_mac[3],
cm_node->rem_mac[4], cm_node->rem_mac[5]);
add_hte_node(cm_core, cm_node); add_hte_node(cm_core, cm_node);
atomic_inc(&cm_nodes_created); atomic_inc(&cm_nodes_created);
......
...@@ -787,16 +787,14 @@ static int nes_netdev_set_mac_address(struct net_device *netdev, void *p) ...@@ -787,16 +787,14 @@ static int nes_netdev_set_mac_address(struct net_device *netdev, void *p)
int i; int i;
u32 macaddr_low; u32 macaddr_low;
u16 macaddr_high; u16 macaddr_high;
DECLARE_MAC_BUF(mac);
if (!is_valid_ether_addr(mac_addr->sa_data)) if (!is_valid_ether_addr(mac_addr->sa_data))
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
memcpy(netdev->dev_addr, mac_addr->sa_data, netdev->addr_len); memcpy(netdev->dev_addr, mac_addr->sa_data, netdev->addr_len);
printk(PFX "%s: Address length = %d, Address = %02X%02X%02X%02X%02X%02X..\n", printk(PFX "%s: Address length = %d, Address = %s\n",
__func__, netdev->addr_len, __func__, netdev->addr_len, print_mac(mac, mac_addr->sa_data));
mac_addr->sa_data[0], mac_addr->sa_data[1],
mac_addr->sa_data[2], mac_addr->sa_data[3],
mac_addr->sa_data[4], mac_addr->sa_data[5]);
macaddr_high = ((u16)netdev->dev_addr[0]) << 8; macaddr_high = ((u16)netdev->dev_addr[0]) << 8;
macaddr_high += (u16)netdev->dev_addr[1]; macaddr_high += (u16)netdev->dev_addr[1];
macaddr_low = ((u32)netdev->dev_addr[2]) << 24; macaddr_low = ((u32)netdev->dev_addr[2]) << 24;
...@@ -878,11 +876,11 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev) ...@@ -878,11 +876,11 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
if (mc_nic_index < 0) if (mc_nic_index < 0)
mc_nic_index = nesvnic->nic_index; mc_nic_index = nesvnic->nic_index;
if (multicast_addr) { if (multicast_addr) {
nes_debug(NES_DBG_NIC_RX, "Assigning MC Address = %02X%02X%02X%02X%02X%02X to register 0x%04X nic_idx=%d\n", DECLARE_MAC_BUF(mac);
multicast_addr->dmi_addr[0], multicast_addr->dmi_addr[1], nes_debug(NES_DBG_NIC_RX, "Assigning MC Address %s to register 0x%04X nic_idx=%d\n",
multicast_addr->dmi_addr[2], multicast_addr->dmi_addr[3], print_mac(mac, multicast_addr->dmi_addr),
multicast_addr->dmi_addr[4], multicast_addr->dmi_addr[5], perfect_filter_register_address+(mc_index * 8),
perfect_filter_register_address+(mc_index * 8), mc_nic_index); mc_nic_index);
macaddr_high = ((u16)multicast_addr->dmi_addr[0]) << 8; macaddr_high = ((u16)multicast_addr->dmi_addr[0]) << 8;
macaddr_high += (u16)multicast_addr->dmi_addr[1]; macaddr_high += (u16)multicast_addr->dmi_addr[1];
macaddr_low = ((u32)multicast_addr->dmi_addr[2]) << 24; macaddr_low = ((u32)multicast_addr->dmi_addr[2]) << 24;
......
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