diff options
author | Grant Erickson <gerickson@nuovations.com> | 2008-07-07 18:03:11 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2008-07-09 02:30:46 -0400 |
commit | 05781ccd74c63c6c8567f99101587d5c07c163e0 (patch) | |
tree | bd1e666433674363e5d0819c08afae87e7105995 /drivers/net/ibm_newemac/core.h | |
parent | 801eb73f45371accc78ca9d6d22d647eeb722c11 (diff) |
ibm_newemac: Parameterize EMAC Multicast Match Handling
Various instances of the EMAC core have varying: 1) number of address
match slots, 2) width of the registers for handling address match slots,
3) number of registers for handling address match slots and 4) base
offset for those registers.
As the driver stands today, it assumes that all EMACs have 4 IAHT and
GAHT 32-bit registers, starting at offset 0x30 from the register base,
with only 16-bits of each used for a total of 64 match slots.
The 405EX(r) and 460EX now use the EMAC4SYNC core rather than the EMAC4
core. This core has 8 IAHT and GAHT registers, starting at offset 0x80
from the register base, with ALL 32-bits of each used for a total of
256 match slots.
This adds a new compatible device tree entry "emac4sync" and a new,
related feature flag "EMAC_FTR_EMAC4SYNC" along with a series of macros
and inlines which supply the appropriate parameterized value based on
the presence or absence of the EMAC4SYNC feature.
The code has further been reworked where appropriate to use those macros
and inlines.
In addition, the register size passed to ioremap is now taken from the
device tree:
c4 for EMAC4SYNC cores
74 for EMAC4 cores
70 for EMAC cores
rather than sizeof (emac_regs).
Finally, the device trees have been updated with the appropriate compatible
entries and resource sizes.
This has been tested on an AMCC Haleakala board such that: 1) inbound
ICMP requests to 'haleakala.local' via MDNS from both Mac OS X 10.4.11
and Ubuntu 8.04 systems as well as 2) outbound ICMP requests from
'haleakala.local' to those same systems in the '.local' domain via MDNS
now work.
Signed-off-by: Grant Erickson <gerickson@nuovations.com>
Acked-by: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'drivers/net/ibm_newemac/core.h')
-rw-r--r-- | drivers/net/ibm_newemac/core.h | 83 |
1 files changed, 82 insertions, 1 deletions
diff --git a/drivers/net/ibm_newemac/core.h b/drivers/net/ibm_newemac/core.h index 223090466760..6545e69d12c3 100644 --- a/drivers/net/ibm_newemac/core.h +++ b/drivers/net/ibm_newemac/core.h | |||
@@ -235,6 +235,10 @@ struct emac_instance { | |||
235 | u32 fifo_entry_size; | 235 | u32 fifo_entry_size; |
236 | u32 mal_burst_size; /* move to MAL ? */ | 236 | u32 mal_burst_size; /* move to MAL ? */ |
237 | 237 | ||
238 | /* IAHT and GAHT filter parameterization */ | ||
239 | u32 xaht_slots_shift; | ||
240 | u32 xaht_width_shift; | ||
241 | |||
238 | /* Descriptor management | 242 | /* Descriptor management |
239 | */ | 243 | */ |
240 | struct mal_descriptor *tx_desc; | 244 | struct mal_descriptor *tx_desc; |
@@ -309,6 +313,10 @@ struct emac_instance { | |||
309 | * Set if we need phy clock workaround for 440ep or 440gr | 313 | * Set if we need phy clock workaround for 440ep or 440gr |
310 | */ | 314 | */ |
311 | #define EMAC_FTR_440EP_PHY_CLK_FIX 0x00000100 | 315 | #define EMAC_FTR_440EP_PHY_CLK_FIX 0x00000100 |
316 | /* | ||
317 | * The 405EX and 460EX contain the EMAC4SYNC core | ||
318 | */ | ||
319 | #define EMAC_FTR_EMAC4SYNC 0x00000200 | ||
312 | 320 | ||
313 | 321 | ||
314 | /* Right now, we don't quite handle the always/possible masks on the | 322 | /* Right now, we don't quite handle the always/possible masks on the |
@@ -320,7 +328,8 @@ enum { | |||
320 | 328 | ||
321 | EMAC_FTRS_POSSIBLE = | 329 | EMAC_FTRS_POSSIBLE = |
322 | #ifdef CONFIG_IBM_NEW_EMAC_EMAC4 | 330 | #ifdef CONFIG_IBM_NEW_EMAC_EMAC4 |
323 | EMAC_FTR_EMAC4 | EMAC_FTR_HAS_NEW_STACR | | 331 | EMAC_FTR_EMAC4 | EMAC_FTR_EMAC4SYNC | |
332 | EMAC_FTR_HAS_NEW_STACR | | ||
324 | EMAC_FTR_STACR_OC_INVERT | EMAC_FTR_440GX_PHY_CLK_FIX | | 333 | EMAC_FTR_STACR_OC_INVERT | EMAC_FTR_440GX_PHY_CLK_FIX | |
325 | #endif | 334 | #endif |
326 | #ifdef CONFIG_IBM_NEW_EMAC_TAH | 335 | #ifdef CONFIG_IBM_NEW_EMAC_TAH |
@@ -342,6 +351,71 @@ static inline int emac_has_feature(struct emac_instance *dev, | |||
342 | (EMAC_FTRS_POSSIBLE & dev->features & feature); | 351 | (EMAC_FTRS_POSSIBLE & dev->features & feature); |
343 | } | 352 | } |
344 | 353 | ||
354 | /* | ||
355 | * Various instances of the EMAC core have varying 1) number of | ||
356 | * address match slots, 2) width of the registers for handling address | ||
357 | * match slots, 3) number of registers for handling address match | ||
358 | * slots and 4) base offset for those registers. | ||
359 | * | ||
360 | * These macros and inlines handle these differences based on | ||
361 | * parameters supplied by the device structure which are, in turn, | ||
362 | * initialized based on the "compatible" entry in the device tree. | ||
363 | */ | ||
364 | |||
365 | #define EMAC4_XAHT_SLOTS_SHIFT 6 | ||
366 | #define EMAC4_XAHT_WIDTH_SHIFT 4 | ||
367 | |||
368 | #define EMAC4SYNC_XAHT_SLOTS_SHIFT 8 | ||
369 | #define EMAC4SYNC_XAHT_WIDTH_SHIFT 5 | ||
370 | |||
371 | #define EMAC_XAHT_SLOTS(dev) (1 << (dev)->xaht_slots_shift) | ||
372 | #define EMAC_XAHT_WIDTH(dev) (1 << (dev)->xaht_width_shift) | ||
373 | #define EMAC_XAHT_REGS(dev) (1 << ((dev)->xaht_slots_shift - \ | ||
374 | (dev)->xaht_width_shift)) | ||
375 | |||
376 | #define EMAC_XAHT_CRC_TO_SLOT(dev, crc) \ | ||
377 | ((EMAC_XAHT_SLOTS(dev) - 1) - \ | ||
378 | ((crc) >> ((sizeof (u32) * BITS_PER_BYTE) - \ | ||
379 | (dev)->xaht_slots_shift))) | ||
380 | |||
381 | #define EMAC_XAHT_SLOT_TO_REG(dev, slot) \ | ||
382 | ((slot) >> (dev)->xaht_width_shift) | ||
383 | |||
384 | #define EMAC_XAHT_SLOT_TO_MASK(dev, slot) \ | ||
385 | ((u32)(1 << (EMAC_XAHT_WIDTH(dev) - 1)) >> \ | ||
386 | ((slot) & (u32)(EMAC_XAHT_WIDTH(dev) - 1))) | ||
387 | |||
388 | static inline u32 *emac_xaht_base(struct emac_instance *dev) | ||
389 | { | ||
390 | struct emac_regs __iomem *p = dev->emacp; | ||
391 | int offset; | ||
392 | |||
393 | /* The first IAHT entry always is the base of the block of | ||
394 | * IAHT and GAHT registers. | ||
395 | */ | ||
396 | if (emac_has_feature(dev, EMAC_FTR_EMAC4SYNC)) | ||
397 | offset = offsetof(struct emac_regs, u1.emac4sync.iaht1); | ||
398 | else | ||
399 | offset = offsetof(struct emac_regs, u0.emac4.iaht1); | ||
400 | |||
401 | return ((u32 *)((ptrdiff_t)p + offset)); | ||
402 | } | ||
403 | |||
404 | static inline u32 *emac_gaht_base(struct emac_instance *dev) | ||
405 | { | ||
406 | /* GAHT registers always come after an identical number of | ||
407 | * IAHT registers. | ||
408 | */ | ||
409 | return (emac_xaht_base(dev) + EMAC_XAHT_REGS(dev)); | ||
410 | } | ||
411 | |||
412 | static inline u32 *emac_iaht_base(struct emac_instance *dev) | ||
413 | { | ||
414 | /* IAHT registers always come before an identical number of | ||
415 | * GAHT registers. | ||
416 | */ | ||
417 | return (emac_xaht_base(dev)); | ||
418 | } | ||
345 | 419 | ||
346 | /* Ethtool get_regs complex data. | 420 | /* Ethtool get_regs complex data. |
347 | * We want to get not just EMAC registers, but also MAL, ZMII, RGMII, TAH | 421 | * We want to get not just EMAC registers, but also MAL, ZMII, RGMII, TAH |
@@ -366,4 +440,11 @@ struct emac_ethtool_regs_subhdr { | |||
366 | u32 index; | 440 | u32 index; |
367 | }; | 441 | }; |
368 | 442 | ||
443 | #define EMAC_ETHTOOL_REGS_VER 0 | ||
444 | #define EMAC_ETHTOOL_REGS_SIZE(dev) ((dev)->rsrc_regs.end - \ | ||
445 | (dev)->rsrc_regs.start + 1) | ||
446 | #define EMAC4_ETHTOOL_REGS_VER 1 | ||
447 | #define EMAC4_ETHTOOL_REGS_SIZE(dev) ((dev)->rsrc_regs.end - \ | ||
448 | (dev)->rsrc_regs.start + 1) | ||
449 | |||
369 | #endif /* __IBM_NEWEMAC_CORE_H */ | 450 | #endif /* __IBM_NEWEMAC_CORE_H */ |