Skip to content

Commit 6ab91e4

Browse files
paulburtondavem330
authored andcommitted
net: pch_gbe: Inline pch_gbe_mac_mc_addr_list_update
The pch_gbe driver sets up multicast address filters using a convoluted mechanism by which pch_gbe_set_multi allocates an array to hold multicast addresses, copies desired addresses into that array, calls a pch_gbe_mac_mc_addr_list_update function which copies addresses out of that array into MAC registers, then frees the array. This patch simplifies this somewhat by inlining pch_gbe_mac_mc_addr_list_update into pch_gbe_set_multi, and removing the requirement for the MAC addresses to stored consecutively in a single array. Signed-off-by: Paul Burton <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 99a9c28 commit 6ab91e4

File tree

1 file changed

+19
-54
lines changed

1 file changed

+19
-54
lines changed

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c

Lines changed: 19 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -411,44 +411,6 @@ static void pch_gbe_mac_init_rx_addrs(struct pch_gbe_hw *hw, u16 mar_count)
411411
pch_gbe_wait_clr_bit(&hw->reg->ADDR_MASK, PCH_GBE_BUSY);
412412
}
413413

414-
415-
/**
416-
* pch_gbe_mac_mc_addr_list_update - Update Multicast addresses
417-
* @hw: Pointer to the HW structure
418-
* @mc_addr_list: Array of multicast addresses to program
419-
* @mc_addr_count: Number of multicast addresses to program
420-
* @mar_used_count: The first MAC Address register free to program
421-
* @mar_total_num: Total number of supported MAC Address Registers
422-
*/
423-
static void pch_gbe_mac_mc_addr_list_update(struct pch_gbe_hw *hw,
424-
u8 *mc_addr_list, u32 mc_addr_count,
425-
u32 mar_used_count, u32 mar_total_num)
426-
{
427-
u32 i, adrmask;
428-
429-
/* Load the first set of multicast addresses into the exact
430-
* filters (RAR). If there are not enough to fill the RAR
431-
* array, clear the filters.
432-
*/
433-
for (i = mar_used_count; i < mar_total_num; i++) {
434-
if (mc_addr_count) {
435-
pch_gbe_mac_mar_set(hw, mc_addr_list, i);
436-
mc_addr_count--;
437-
mc_addr_list += ETH_ALEN;
438-
} else {
439-
/* Clear MAC address mask */
440-
adrmask = ioread32(&hw->reg->ADDR_MASK);
441-
iowrite32((adrmask | (0x0001 << i)),
442-
&hw->reg->ADDR_MASK);
443-
/* wait busy */
444-
pch_gbe_wait_clr_bit(&hw->reg->ADDR_MASK, PCH_GBE_BUSY);
445-
/* Clear MAC address */
446-
iowrite32(0, &hw->reg->mac_adr[i].high);
447-
iowrite32(0, &hw->reg->mac_adr[i].low);
448-
}
449-
}
450-
}
451-
452414
/**
453415
* pch_gbe_mac_force_mac_fc - Force the MAC's flow control settings
454416
* @hw: Pointer to the HW structure
@@ -2143,10 +2105,8 @@ static void pch_gbe_set_multi(struct net_device *netdev)
21432105
struct pch_gbe_adapter *adapter = netdev_priv(netdev);
21442106
struct pch_gbe_hw *hw = &adapter->hw;
21452107
struct netdev_hw_addr *ha;
2146-
u8 *mta_list;
2147-
u32 rctl;
2148-
int i;
2149-
int mc_count;
2108+
u32 rctl, adrmask;
2109+
int mc_count, i;
21502110

21512111
netdev_dbg(netdev, "netdev->flags : 0x%08x\n", netdev->flags);
21522112

@@ -2173,20 +2133,25 @@ static void pch_gbe_set_multi(struct net_device *netdev)
21732133

21742134
if (mc_count >= PCH_GBE_MAR_ENTRIES)
21752135
return;
2176-
mta_list = kmalloc_array(ETH_ALEN, mc_count, GFP_ATOMIC);
2177-
if (!mta_list)
2178-
return;
21792136

2180-
/* The shared function expects a packed array of only addresses. */
2181-
i = 0;
2182-
netdev_for_each_mc_addr(ha, netdev) {
2183-
if (i == mc_count)
2184-
break;
2185-
memcpy(mta_list + (i++ * ETH_ALEN), &ha->addr, ETH_ALEN);
2137+
/* Load the first set of multicast addresses into MAC address registers
2138+
* for use by hardware filtering.
2139+
*/
2140+
i = 1;
2141+
netdev_for_each_mc_addr(ha, netdev)
2142+
pch_gbe_mac_mar_set(hw, ha->addr, i++);
2143+
2144+
/* If there are spare MAC registers, mask & clear them */
2145+
for (; i < PCH_GBE_MAR_ENTRIES; i++) {
2146+
/* Clear MAC address mask */
2147+
adrmask = ioread32(&hw->reg->ADDR_MASK);
2148+
iowrite32(adrmask | BIT(i), &hw->reg->ADDR_MASK);
2149+
/* wait busy */
2150+
pch_gbe_wait_clr_bit(&hw->reg->ADDR_MASK, PCH_GBE_BUSY);
2151+
/* Clear MAC address */
2152+
iowrite32(0, &hw->reg->mac_adr[i].high);
2153+
iowrite32(0, &hw->reg->mac_adr[i].low);
21862154
}
2187-
pch_gbe_mac_mc_addr_list_update(hw, mta_list, i, 1,
2188-
PCH_GBE_MAR_ENTRIES);
2189-
kfree(mta_list);
21902155

21912156
netdev_dbg(netdev,
21922157
"RX_MODE reg(check bit31,30 ADD,MLT) : 0x%08x netdev->mc_count : 0x%08x\n",

0 commit comments

Comments
 (0)