47 #include <linux/slab.h>
49 #define OFFSET(REG_ADDR) ((REG_ADDR) << 2)
52 #define MAX_FRAME_SIZE 9600
55 #define TXXG_CONF1_VAL ((IPG << SUNI1x10GEXP_BITOFF_TXXG_IPGT) | \
56 SUNI1x10GEXP_BITMSK_TXXG_32BIT_ALIGN | SUNI1x10GEXP_BITMSK_TXXG_CRCEN | \
57 SUNI1x10GEXP_BITMSK_TXXG_PADEN)
58 #define RXXG_CONF1_VAL (SUNI1x10GEXP_BITMSK_RXXG_PUREP | 0x14 | \
59 SUNI1x10GEXP_BITMSK_RXXG_FLCHK | SUNI1x10GEXP_BITMSK_RXXG_CRC_STRIP)
62 #define STATS_TICK_SECS (15 * 60)
111 static int pm3393_reset(
struct cmac *cmac)
124 static int pm3393_interrupt_enable(
struct cmac *cmac)
164 static int pm3393_interrupt_disable(
struct cmac *cmac)
203 static int pm3393_interrupt_clear(
struct cmac *cmac)
248 static int pm3393_interrupt_handler(
struct cmac *cmac)
250 u32 master_intr_status;
254 &master_intr_status);
260 pm3393_interrupt_clear(cmac);
265 static int pm3393_enable(
struct cmac *cmac,
int which)
285 static int pm3393_enable_port(
struct cmac *cmac,
int which)
293 pm3393_enable(cmac, which);
304 static int pm3393_disable(
struct cmac *cmac,
int which)
306 if (which & MAC_DIRECTION_RX)
308 if (which & MAC_DIRECTION_TX)
321 static int pm3393_loopback_enable(
struct cmac *cmac)
326 static int pm3393_loopback_disable(
struct cmac *cmac)
331 static int pm3393_set_mtu(
struct cmac *cmac,
int mtu)
342 pm3393_disable(cmac, MAC_DIRECTION_RX | MAC_DIRECTION_TX);
348 pm3393_enable(cmac, enabled);
352 static int pm3393_set_rx_mode(
struct cmac *cmac,
struct t1_rx_mode *rm)
359 pm3393_disable(cmac, MAC_DIRECTION_RX);
382 u16 mc_filter[4] = { 0, };
387 mc_filter[bit >> 4] |= 1 << (bit & 0xf);
399 pm3393_enable(cmac, MAC_DIRECTION_RX);
404 static int pm3393_get_speed_duplex_fc(
struct cmac *cmac,
int *speed,
416 static int pm3393_set_speed_duplex_fc(
struct cmac *cmac,
int speed,
int duplex,
429 pm3393_enable(cmac, MAC_DIRECTION_TX);
434 #define RMON_UPDATE(mac, name, stat_name) \
436 t1_tpi_read((mac)->adapter, OFFSET(name), &val0); \
437 t1_tpi_read((mac)->adapter, OFFSET((name)+1), &val1); \
438 t1_tpi_read((mac)->adapter, OFFSET((name)+2), &val2); \
439 (mac)->stats.stat_name = (u64)(val0 & 0xffff) | \
440 ((u64)(val1 & 0xffff) << 16) | \
441 ((u64)(val2 & 0xff) << 32) | \
442 ((mac)->stats.stat_name & \
443 0xffffff0000000000ULL); \
445 (1ULL << ((name - SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW) >> 2))) \
446 (mac)->stats.stat_name += 1ULL << 40; \
453 u32 val0, val1, val2, val3;
464 ro = ((
u64)val0 & 0xffff) | (((
u64)val1 & 0xffff) << 16) |
465 (((
u64)val2 & 0xffff) << 32) | (((
u64)val3 & 0xffff) << 48);
500 static int pm3393_macaddress_get(
struct cmac *cmac,
u8 mac_addr[6])
506 static int pm3393_macaddress_set(
struct cmac *cmac,
u8 ma[6])
531 lo = ((
u32) ma[1] << 8) | (
u32) ma[0];
532 mid = ((
u32) ma[3] << 8) | (
u32) ma[2];
533 hi = ((
u32) ma[5] << 8) | (
u32) ma[4];
537 pm3393_disable(cmac, MAC_DIRECTION_RX | MAC_DIRECTION_TX);
565 pm3393_enable(cmac, enabled);
569 static void pm3393_destroy(
struct cmac *cmac)
574 static struct cmac_ops pm3393_ops = {
575 .destroy = pm3393_destroy,
576 .reset = pm3393_reset,
577 .interrupt_enable = pm3393_interrupt_enable,
578 .interrupt_disable = pm3393_interrupt_disable,
579 .interrupt_clear = pm3393_interrupt_clear,
580 .interrupt_handler = pm3393_interrupt_handler,
581 .enable = pm3393_enable_port,
582 .disable = pm3393_disable,
583 .loopback_enable = pm3393_loopback_enable,
584 .loopback_disable = pm3393_loopback_disable,
585 .set_mtu = pm3393_set_mtu,
586 .set_rx_mode = pm3393_set_rx_mode,
587 .get_speed_duplex_fc = pm3393_get_speed_duplex_fc,
588 .set_speed_duplex_fc = pm3393_set_speed_duplex_fc,
589 .statistics_update = pm3393_update_statistics,
590 .macaddress_get = pm3393_macaddress_get,
591 .macaddress_set = pm3393_macaddress_set
602 cmac->
ops = &pm3393_ops;
691 static int pm3393_mac_reset(
adapter_t * adapter)
695 u32 is_pl4_reset_finished;
696 u32 is_pl4_outof_lock;
697 u32 is_xaui_mabc_pll_locked;
698 u32 successful_reset;
730 successful_reset = 0;
731 for (i = 0; i < 3 && !successful_reset; i++) {
771 is_pl4_outof_lock = (val &
x);
776 is_xaui_mabc_pll_locked =
779 successful_reset = (is_pl4_reset_finished && !is_pl4_outof_lock
780 && is_xaui_mabc_pll_locked);
784 "PM3393 HW reset %d: pl4_reset 0x%x, val 0x%x, "
785 "is_pl4_outof_lock 0x%x, xaui_locked 0x%x\n",
786 i, is_pl4_reset_finished, val,
787 is_pl4_outof_lock, is_xaui_mabc_pll_locked);
789 return successful_reset ? 0 : 1;
794 .create = pm3393_mac_create,
795 .reset = pm3393_mac_reset,