3 * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
5 * Copyright © 2005 Agere Systems Inc.
9 * Copyright (c) 2011 Mark Einon <mark.einon@gmail.com>
11 *------------------------------------------------------------------------------
13 * et1310_mac.c - All code and routines pertaining to the MAC
15 *------------------------------------------------------------------------------
19 * This software is provided subject to the following terms and conditions,
20 * which you should read carefully before using the software. Using this
21 * software indicates your acceptance of these terms and conditions. If you do
22 * not agree with these terms and conditions, do not use the software.
24 * Copyright © 2005 Agere Systems Inc.
25 * All rights reserved.
27 * Redistribution and use in source or binary forms, with or without
28 * modifications, are permitted provided that the following conditions are met:
30 * . Redistributions of source code must retain the above copyright notice, this
31 * list of conditions and the following Disclaimer as comments in the code as
32 * well as in the documentation and/or other materials provided with the
35 * . Redistributions in binary form must reproduce the above copyright notice,
36 * this list of conditions and the following Disclaimer in the documentation
37 * and/or other materials provided with the distribution.
39 * . Neither the name of Agere Systems Inc. nor the names of the contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
45 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
46 * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
47 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
48 * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
49 * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY
50 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
51 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
52 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
53 * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT
54 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
55 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
60 #include "et131x_version.h"
61 #include "et131x_defs.h"
63 #include <linux/init.h>
64 #include <linux/module.h>
65 #include <linux/types.h>
66 #include <linux/kernel.h>
68 #include <linux/sched.h>
69 #include <linux/ptrace.h>
70 #include <linux/ctype.h>
71 #include <linux/string.h>
72 #include <linux/timer.h>
73 #include <linux/interrupt.h>
75 #include <linux/delay.h>
77 #include <linux/bitops.h>
78 #include <linux/pci.h>
79 #include <asm/system.h>
81 #include <linux/netdevice.h>
82 #include <linux/etherdevice.h>
83 #include <linux/skbuff.h>
84 #include <linux/if_arp.h>
85 #include <linux/ioport.h>
86 #include <linux/crc32.h>
87 #include <linux/phy.h>
89 #include "et1310_phy.h"
90 #include "et131x_adapter.h"
94 #define COUNTER_WRAP_28_BIT 0x10000000
95 #define COUNTER_WRAP_22_BIT 0x400000
96 #define COUNTER_WRAP_16_BIT 0x10000
97 #define COUNTER_WRAP_12_BIT 0x1000
99 #define COUNTER_MASK_28_BIT (COUNTER_WRAP_28_BIT - 1)
100 #define COUNTER_MASK_22_BIT (COUNTER_WRAP_22_BIT - 1)
101 #define COUNTER_MASK_16_BIT (COUNTER_WRAP_16_BIT - 1)
102 #define COUNTER_MASK_12_BIT (COUNTER_WRAP_12_BIT - 1)
105 * et1310_config_mac_regs1 - Initialize the first part of MAC regs
106 * @adapter: pointer to our adapter structure
108 void et1310_config_mac_regs1(struct et131x_adapter
*adapter
)
110 struct mac_regs __iomem
*macregs
= &adapter
->regs
->mac
;
115 /* First we need to reset everything. Write to MAC configuration
116 * register 1 to perform reset.
118 writel(0xC00F0000, ¯egs
->cfg1
);
120 /* Next lets configure the MAC Inter-packet gap register */
121 ipg
= 0x38005860; /* IPG1 0x38 IPG2 0x58 B2B 0x60 */
122 ipg
|= 0x50 << 8; /* ifg enforce 0x50 */
123 writel(ipg
, ¯egs
->ipg
);
125 /* Next lets configure the MAC Half Duplex register */
126 /* BEB trunc 0xA, Ex Defer, Rexmit 0xF Coll 0x37 */
127 writel(0x00A1F037, ¯egs
->hfdp
);
129 /* Next lets configure the MAC Interface Control register */
130 writel(0, ¯egs
->if_ctrl
);
132 /* Let's move on to setting up the mii management configuration */
133 writel(0x07, ¯egs
->mii_mgmt_cfg
); /* Clock reset 0x7 */
135 /* Next lets configure the MAC Station Address register. These
136 * values are read from the EEPROM during initialization and stored
137 * in the adapter structure. We write what is stored in the adapter
138 * structure to the MAC Station Address registers high and low. This
139 * station address is used for generating and checking pause control
142 station2
= (adapter
->addr
[1] << ET_MAC_STATION_ADDR2_OC2_SHIFT
) |
143 (adapter
->addr
[0] << ET_MAC_STATION_ADDR2_OC1_SHIFT
);
144 station1
= (adapter
->addr
[5] << ET_MAC_STATION_ADDR1_OC6_SHIFT
) |
145 (adapter
->addr
[4] << ET_MAC_STATION_ADDR1_OC5_SHIFT
) |
146 (adapter
->addr
[3] << ET_MAC_STATION_ADDR1_OC4_SHIFT
) |
148 writel(station1
, ¯egs
->station_addr_1
);
149 writel(station2
, ¯egs
->station_addr_2
);
151 /* Max ethernet packet in bytes that will passed by the mac without
152 * being truncated. Allow the MAC to pass 4 more than our max packet
153 * size. This is 4 for the Ethernet CRC.
155 * Packets larger than (registry_jumbo_packet) that do not contain a
156 * VLAN ID will be dropped by the Rx function.
158 writel(adapter
->registry_jumbo_packet
+ 4, ¯egs
->max_fm_len
);
160 /* clear out MAC config reset */
161 writel(0, ¯egs
->cfg1
);
165 * et1310_config_mac_regs2 - Initialize the second part of MAC regs
166 * @adapter: pointer to our adapter structure
168 void et1310_config_mac_regs2(struct et131x_adapter
*adapter
)
171 struct mac_regs __iomem
*mac
= &adapter
->regs
->mac
;
172 struct phy_device
*phydev
= adapter
->phydev
;
178 ctl
= readl(&adapter
->regs
->txmac
.ctl
);
179 cfg1
= readl(&mac
->cfg1
);
180 cfg2
= readl(&mac
->cfg2
);
181 ifctrl
= readl(&mac
->if_ctrl
);
183 /* Set up the if mode bits */
185 if (phydev
&& phydev
->speed
== SPEED_1000
) {
188 ifctrl
&= ~(1 << 24);
194 /* We need to enable Rx/Tx */
195 cfg1
|= CFG1_RX_ENABLE
| CFG1_TX_ENABLE
| CFG1_TX_FLOW
;
196 /* Initialize loop back to off */
197 cfg1
&= ~(CFG1_LOOPBACK
| CFG1_RX_FLOW
);
198 if (adapter
->flowcontrol
== FLOW_RXONLY
||
199 adapter
->flowcontrol
== FLOW_BOTH
)
200 cfg1
|= CFG1_RX_FLOW
;
201 writel(cfg1
, &mac
->cfg1
);
203 /* Now we need to initialize the MAC Configuration 2 register */
204 /* preamble 7, check length, huge frame off, pad crc, crc enable
209 /* Turn on duplex if needed */
210 if (phydev
&& phydev
->duplex
== DUPLEX_FULL
)
213 ifctrl
&= ~(1 << 26);
214 if (phydev
&& phydev
->duplex
== DUPLEX_HALF
)
215 ifctrl
|= (1<<26); /* Enable ghd */
217 writel(ifctrl
, &mac
->if_ctrl
);
218 writel(cfg2
, &mac
->cfg2
);
223 cfg1
= readl(&mac
->cfg1
);
224 } while ((cfg1
& CFG1_WAIT
) != CFG1_WAIT
&& delay
< 100);
227 dev_warn(&adapter
->pdev
->dev
,
228 "Syncd bits did not respond correctly cfg1 word 0x%08x\n",
233 ctl
|= 0x09; /* TX mac enable, FC disable */
234 writel(ctl
, &adapter
->regs
->txmac
.ctl
);
236 /* Ready to start the RXDMA/TXDMA engine */
237 if (adapter
->flags
& fMP_ADAPTER_LOWER_POWER
) {
238 et131x_rx_dma_enable(adapter
);
239 et131x_tx_dma_enable(adapter
);
243 void et1310_config_rxmac_regs(struct et131x_adapter
*adapter
)
245 struct rxmac_regs __iomem
*rxmac
= &adapter
->regs
->rxmac
;
246 struct phy_device
*phydev
= adapter
->phydev
;
251 /* Disable the MAC while it is being configured (also disable WOL) */
252 writel(0x8, &rxmac
->ctrl
);
254 /* Initialize WOL to disabled. */
255 writel(0, &rxmac
->crc0
);
256 writel(0, &rxmac
->crc12
);
257 writel(0, &rxmac
->crc34
);
259 /* We need to set the WOL mask0 - mask4 next. We initialize it to
260 * its default Values of 0x00000000 because there are not WOL masks
263 writel(0, &rxmac
->mask0_word0
);
264 writel(0, &rxmac
->mask0_word1
);
265 writel(0, &rxmac
->mask0_word2
);
266 writel(0, &rxmac
->mask0_word3
);
268 writel(0, &rxmac
->mask1_word0
);
269 writel(0, &rxmac
->mask1_word1
);
270 writel(0, &rxmac
->mask1_word2
);
271 writel(0, &rxmac
->mask1_word3
);
273 writel(0, &rxmac
->mask2_word0
);
274 writel(0, &rxmac
->mask2_word1
);
275 writel(0, &rxmac
->mask2_word2
);
276 writel(0, &rxmac
->mask2_word3
);
278 writel(0, &rxmac
->mask3_word0
);
279 writel(0, &rxmac
->mask3_word1
);
280 writel(0, &rxmac
->mask3_word2
);
281 writel(0, &rxmac
->mask3_word3
);
283 writel(0, &rxmac
->mask4_word0
);
284 writel(0, &rxmac
->mask4_word1
);
285 writel(0, &rxmac
->mask4_word2
);
286 writel(0, &rxmac
->mask4_word3
);
288 /* Lets setup the WOL Source Address */
289 sa_lo
= (adapter
->addr
[2] << ET_WOL_LO_SA3_SHIFT
) |
290 (adapter
->addr
[3] << ET_WOL_LO_SA4_SHIFT
) |
291 (adapter
->addr
[4] << ET_WOL_LO_SA5_SHIFT
) |
293 writel(sa_lo
, &rxmac
->sa_lo
);
295 sa_hi
= (u32
) (adapter
->addr
[0] << ET_WOL_HI_SA1_SHIFT
) |
297 writel(sa_hi
, &rxmac
->sa_hi
);
299 /* Disable all Packet Filtering */
300 writel(0, &rxmac
->pf_ctrl
);
302 /* Let's initialize the Unicast Packet filtering address */
303 if (adapter
->packet_filter
& ET131X_PACKET_TYPE_DIRECTED
) {
304 et1310_setup_device_for_unicast(adapter
);
305 pf_ctrl
|= 4; /* Unicast filter */
307 writel(0, &rxmac
->uni_pf_addr1
);
308 writel(0, &rxmac
->uni_pf_addr2
);
309 writel(0, &rxmac
->uni_pf_addr3
);
312 /* Let's initialize the Multicast hash */
313 if (!(adapter
->packet_filter
& ET131X_PACKET_TYPE_ALL_MULTICAST
)) {
314 pf_ctrl
|= 2; /* Multicast filter */
315 et1310_setup_device_for_multicast(adapter
);
318 /* Runt packet filtering. Didn't work in version A silicon. */
319 pf_ctrl
|= (NIC_MIN_PACKET_SIZE
+ 4) << 16;
320 pf_ctrl
|= 8; /* Fragment filter */
322 if (adapter
->registry_jumbo_packet
> 8192)
323 /* In order to transmit jumbo packets greater than 8k, the
324 * FIFO between RxMAC and RxDMA needs to be reduced in size
325 * to (16k - Jumbo packet size). In order to implement this,
326 * we must use "cut through" mode in the RxMAC, which chops
327 * packets down into segments which are (max_size * 16). In
328 * this case we selected 256 bytes, since this is the size of
329 * the PCI-Express TLP's that the 1310 uses.
331 * seg_en on, fc_en off, size 0x10
333 writel(0x41, &rxmac
->mcif_ctrl_max_seg
);
335 writel(0, &rxmac
->mcif_ctrl_max_seg
);
337 /* Initialize the MCIF water marks */
338 writel(0, &rxmac
->mcif_water_mark
);
340 /* Initialize the MIF control */
341 writel(0, &rxmac
->mif_ctrl
);
343 /* Initialize the Space Available Register */
344 writel(0, &rxmac
->space_avail
);
346 /* Initialize the the mif_ctrl register
347 * bit 3: Receive code error. One or more nibbles were signaled as
348 * errors during the reception of the packet. Clear this
349 * bit in Gigabit, set it in 100Mbit. This was derived
350 * experimentally at UNH.
351 * bit 4: Receive CRC error. The packet's CRC did not match the
352 * internally generated CRC.
353 * bit 5: Receive length check error. Indicates that frame length
354 * field value in the packet does not match the actual data
355 * byte length and is not a type field.
356 * bit 16: Receive frame truncated.
357 * bit 17: Drop packet enable
359 if (phydev
&& phydev
->speed
== SPEED_100
)
360 writel(0x30038, &rxmac
->mif_ctrl
);
362 writel(0x30030, &rxmac
->mif_ctrl
);
364 /* Finally we initialize RxMac to be enabled & WOL disabled. Packet
365 * filter is always enabled since it is where the runt packets are
366 * supposed to be dropped. For version A silicon, runt packet
367 * dropping doesn't work, so it is disabled in the pf_ctrl register,
368 * but we still leave the packet filter on.
370 writel(pf_ctrl
, &rxmac
->pf_ctrl
);
371 writel(0x9, &rxmac
->ctrl
);
374 void et1310_config_txmac_regs(struct et131x_adapter
*adapter
)
376 struct txmac_regs
*txmac
= &adapter
->regs
->txmac
;
378 /* We need to update the Control Frame Parameters
379 * cfpt - control frame pause timer set to 64 (0x40)
380 * cfep - control frame extended pause timer set to 0x0
382 if (adapter
->flowcontrol
== FLOW_NONE
)
383 writel(0, &txmac
->cf_param
);
385 writel(0x40, &txmac
->cf_param
);
388 void et1310_config_macstat_regs(struct et131x_adapter
*adapter
)
390 struct macstat_regs __iomem
*macstat
=
391 &adapter
->regs
->macstat
;
393 /* Next we need to initialize all the macstat registers to zero on
396 writel(0, &macstat
->txrx_0_64_byte_frames
);
397 writel(0, &macstat
->txrx_65_127_byte_frames
);
398 writel(0, &macstat
->txrx_128_255_byte_frames
);
399 writel(0, &macstat
->txrx_256_511_byte_frames
);
400 writel(0, &macstat
->txrx_512_1023_byte_frames
);
401 writel(0, &macstat
->txrx_1024_1518_byte_frames
);
402 writel(0, &macstat
->txrx_1519_1522_gvln_frames
);
404 writel(0, &macstat
->rx_bytes
);
405 writel(0, &macstat
->rx_packets
);
406 writel(0, &macstat
->rx_fcs_errs
);
407 writel(0, &macstat
->rx_multicast_packets
);
408 writel(0, &macstat
->rx_broadcast_packets
);
409 writel(0, &macstat
->rx_control_frames
);
410 writel(0, &macstat
->rx_pause_frames
);
411 writel(0, &macstat
->rx_unknown_opcodes
);
412 writel(0, &macstat
->rx_align_errs
);
413 writel(0, &macstat
->rx_frame_len_errs
);
414 writel(0, &macstat
->rx_code_errs
);
415 writel(0, &macstat
->rx_carrier_sense_errs
);
416 writel(0, &macstat
->rx_undersize_packets
);
417 writel(0, &macstat
->rx_oversize_packets
);
418 writel(0, &macstat
->rx_fragment_packets
);
419 writel(0, &macstat
->rx_jabbers
);
420 writel(0, &macstat
->rx_drops
);
422 writel(0, &macstat
->tx_bytes
);
423 writel(0, &macstat
->tx_packets
);
424 writel(0, &macstat
->tx_multicast_packets
);
425 writel(0, &macstat
->tx_broadcast_packets
);
426 writel(0, &macstat
->tx_pause_frames
);
427 writel(0, &macstat
->tx_deferred
);
428 writel(0, &macstat
->tx_excessive_deferred
);
429 writel(0, &macstat
->tx_single_collisions
);
430 writel(0, &macstat
->tx_multiple_collisions
);
431 writel(0, &macstat
->tx_late_collisions
);
432 writel(0, &macstat
->tx_excessive_collisions
);
433 writel(0, &macstat
->tx_total_collisions
);
434 writel(0, &macstat
->tx_pause_honored_frames
);
435 writel(0, &macstat
->tx_drops
);
436 writel(0, &macstat
->tx_jabbers
);
437 writel(0, &macstat
->tx_fcs_errs
);
438 writel(0, &macstat
->tx_control_frames
);
439 writel(0, &macstat
->tx_oversize_frames
);
440 writel(0, &macstat
->tx_undersize_frames
);
441 writel(0, &macstat
->tx_fragments
);
442 writel(0, &macstat
->carry_reg1
);
443 writel(0, &macstat
->carry_reg2
);
445 /* Unmask any counters that we want to track the overflow of.
446 * Initially this will be all counters. It may become clear later
447 * that we do not need to track all counters.
449 writel(0xFFFFBE32, &macstat
->carry_reg1_mask
);
450 writel(0xFFFE7E8B, &macstat
->carry_reg2_mask
);
453 void et1310_config_flow_control(struct et131x_adapter
*adapter
)
455 struct phy_device
*phydev
= adapter
->phydev
;
457 if (phydev
->duplex
== DUPLEX_HALF
) {
458 adapter
->flowcontrol
= FLOW_NONE
;
460 char remote_pause
, remote_async_pause
;
462 et1310_phy_access_mii_bit(adapter
,
463 TRUEPHY_BIT_READ
, 5, 10, &remote_pause
);
464 et1310_phy_access_mii_bit(adapter
,
465 TRUEPHY_BIT_READ
, 5, 11,
466 &remote_async_pause
);
468 if ((remote_pause
== TRUEPHY_BIT_SET
) &&
469 (remote_async_pause
== TRUEPHY_BIT_SET
)) {
470 adapter
->flowcontrol
= adapter
->wanted_flow
;
471 } else if ((remote_pause
== TRUEPHY_BIT_SET
) &&
472 (remote_async_pause
== TRUEPHY_BIT_CLEAR
)) {
473 if (adapter
->wanted_flow
== FLOW_BOTH
)
474 adapter
->flowcontrol
= FLOW_BOTH
;
476 adapter
->flowcontrol
= FLOW_NONE
;
477 } else if ((remote_pause
== TRUEPHY_BIT_CLEAR
) &&
478 (remote_async_pause
== TRUEPHY_BIT_CLEAR
)) {
479 adapter
->flowcontrol
= FLOW_NONE
;
480 } else {/* if (remote_pause == TRUEPHY_CLEAR_BIT &&
481 remote_async_pause == TRUEPHY_SET_BIT) */
482 if (adapter
->wanted_flow
== FLOW_BOTH
)
483 adapter
->flowcontrol
= FLOW_RXONLY
;
485 adapter
->flowcontrol
= FLOW_NONE
;
491 * et1310_update_macstat_host_counters - Update the local copy of the statistics
492 * @adapter: pointer to the adapter structure
494 void et1310_update_macstat_host_counters(struct et131x_adapter
*adapter
)
496 struct ce_stats
*stats
= &adapter
->stats
;
497 struct macstat_regs __iomem
*macstat
=
498 &adapter
->regs
->macstat
;
500 stats
->tx_collisions
+= readl(&macstat
->tx_total_collisions
);
501 stats
->tx_first_collisions
+= readl(&macstat
->tx_single_collisions
);
502 stats
->tx_deferred
+= readl(&macstat
->tx_deferred
);
503 stats
->tx_excessive_collisions
+=
504 readl(&macstat
->tx_multiple_collisions
);
505 stats
->tx_late_collisions
+= readl(&macstat
->tx_late_collisions
);
506 stats
->tx_underflows
+= readl(&macstat
->tx_undersize_frames
);
507 stats
->tx_max_pkt_errs
+= readl(&macstat
->tx_oversize_frames
);
509 stats
->rx_align_errs
+= readl(&macstat
->rx_align_errs
);
510 stats
->rx_crc_errs
+= readl(&macstat
->rx_code_errs
);
511 stats
->rcvd_pkts_dropped
+= readl(&macstat
->rx_drops
);
512 stats
->rx_overflows
+= readl(&macstat
->rx_oversize_packets
);
513 stats
->rx_code_violations
+= readl(&macstat
->rx_fcs_errs
);
514 stats
->rx_length_errs
+= readl(&macstat
->rx_frame_len_errs
);
515 stats
->rx_other_errs
+= readl(&macstat
->rx_fragment_packets
);
519 * et1310_handle_macstat_interrupt
520 * @adapter: pointer to the adapter structure
522 * One of the MACSTAT counters has wrapped. Update the local copy of
523 * the statistics held in the adapter structure, checking the "wrap"
524 * bit for each counter.
526 void et1310_handle_macstat_interrupt(struct et131x_adapter
*adapter
)
531 /* Read the interrupt bits from the register(s). These are Clear On
534 carry_reg1
= readl(&adapter
->regs
->macstat
.carry_reg1
);
535 carry_reg2
= readl(&adapter
->regs
->macstat
.carry_reg2
);
537 writel(carry_reg1
, &adapter
->regs
->macstat
.carry_reg1
);
538 writel(carry_reg2
, &adapter
->regs
->macstat
.carry_reg2
);
540 /* We need to do update the host copy of all the MAC_STAT counters.
541 * For each counter, check it's overflow bit. If the overflow bit is
542 * set, then increment the host version of the count by one complete
543 * revolution of the counter. This routine is called when the counter
544 * block indicates that one of the counters has wrapped.
546 if (carry_reg1
& (1 << 14))
547 adapter
->stats
.rx_code_violations
+= COUNTER_WRAP_16_BIT
;
548 if (carry_reg1
& (1 << 8))
549 adapter
->stats
.rx_align_errs
+= COUNTER_WRAP_12_BIT
;
550 if (carry_reg1
& (1 << 7))
551 adapter
->stats
.rx_length_errs
+= COUNTER_WRAP_16_BIT
;
552 if (carry_reg1
& (1 << 2))
553 adapter
->stats
.rx_other_errs
+= COUNTER_WRAP_16_BIT
;
554 if (carry_reg1
& (1 << 6))
555 adapter
->stats
.rx_crc_errs
+= COUNTER_WRAP_16_BIT
;
556 if (carry_reg1
& (1 << 3))
557 adapter
->stats
.rx_overflows
+= COUNTER_WRAP_16_BIT
;
558 if (carry_reg1
& (1 << 0))
559 adapter
->stats
.rcvd_pkts_dropped
+= COUNTER_WRAP_16_BIT
;
560 if (carry_reg2
& (1 << 16))
561 adapter
->stats
.tx_max_pkt_errs
+= COUNTER_WRAP_12_BIT
;
562 if (carry_reg2
& (1 << 15))
563 adapter
->stats
.tx_underflows
+= COUNTER_WRAP_12_BIT
;
564 if (carry_reg2
& (1 << 6))
565 adapter
->stats
.tx_first_collisions
+= COUNTER_WRAP_12_BIT
;
566 if (carry_reg2
& (1 << 8))
567 adapter
->stats
.tx_deferred
+= COUNTER_WRAP_12_BIT
;
568 if (carry_reg2
& (1 << 5))
569 adapter
->stats
.tx_excessive_collisions
+= COUNTER_WRAP_12_BIT
;
570 if (carry_reg2
& (1 << 4))
571 adapter
->stats
.tx_late_collisions
+= COUNTER_WRAP_12_BIT
;
572 if (carry_reg2
& (1 << 2))
573 adapter
->stats
.tx_collisions
+= COUNTER_WRAP_12_BIT
;
576 void et1310_setup_device_for_multicast(struct et131x_adapter
*adapter
)
578 struct rxmac_regs __iomem
*rxmac
= &adapter
->regs
->rxmac
;
587 /* If ET131X_PACKET_TYPE_MULTICAST is specified, then we provision
588 * the multi-cast LIST. If it is NOT specified, (and "ALL" is not
589 * specified) then we should pass NO multi-cast addresses to the
592 if (adapter
->packet_filter
& ET131X_PACKET_TYPE_MULTICAST
) {
593 /* Loop through our multicast array and set up the device */
594 for (nIndex
= 0; nIndex
< adapter
->multicast_addr_count
;
596 result
= ether_crc(6, adapter
->multicast_list
[nIndex
]);
598 result
= (result
& 0x3F800000) >> 23;
601 hash1
|= (1 << result
);
602 } else if ((31 < result
) && (result
< 64)) {
604 hash2
|= (1 << result
);
605 } else if ((63 < result
) && (result
< 96)) {
607 hash3
|= (1 << result
);
610 hash4
|= (1 << result
);
615 /* Write out the new hash to the device */
616 pm_csr
= readl(&adapter
->regs
->global
.pm_csr
);
617 if (!et1310_in_phy_coma(adapter
)) {
618 writel(hash1
, &rxmac
->multi_hash1
);
619 writel(hash2
, &rxmac
->multi_hash2
);
620 writel(hash3
, &rxmac
->multi_hash3
);
621 writel(hash4
, &rxmac
->multi_hash4
);
625 void et1310_setup_device_for_unicast(struct et131x_adapter
*adapter
)
627 struct rxmac_regs __iomem
*rxmac
= &adapter
->regs
->rxmac
;
633 /* Set up unicast packet filter reg 3 to be the first two octets of
634 * the MAC address for both address
636 * Set up unicast packet filter reg 2 to be the octets 2 - 5 of the
637 * MAC address for second address
639 * Set up unicast packet filter reg 3 to be the octets 2 - 5 of the
640 * MAC address for first address
642 uni_pf3
= (adapter
->addr
[0] << ET_UNI_PF_ADDR2_1_SHIFT
) |
643 (adapter
->addr
[1] << ET_UNI_PF_ADDR2_2_SHIFT
) |
644 (adapter
->addr
[0] << ET_UNI_PF_ADDR1_1_SHIFT
) |
647 uni_pf2
= (adapter
->addr
[2] << ET_UNI_PF_ADDR2_3_SHIFT
) |
648 (adapter
->addr
[3] << ET_UNI_PF_ADDR2_4_SHIFT
) |
649 (adapter
->addr
[4] << ET_UNI_PF_ADDR2_5_SHIFT
) |
652 uni_pf1
= (adapter
->addr
[2] << ET_UNI_PF_ADDR1_3_SHIFT
) |
653 (adapter
->addr
[3] << ET_UNI_PF_ADDR1_4_SHIFT
) |
654 (adapter
->addr
[4] << ET_UNI_PF_ADDR1_5_SHIFT
) |
657 pm_csr
= readl(&adapter
->regs
->global
.pm_csr
);
658 if (!et1310_in_phy_coma(adapter
)) {
659 writel(uni_pf1
, &rxmac
->uni_pf_addr1
);
660 writel(uni_pf2
, &rxmac
->uni_pf_addr2
);
661 writel(uni_pf3
, &rxmac
->uni_pf_addr3
);