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_defs.h"
62 #include <linux/init.h>
63 #include <linux/module.h>
64 #include <linux/types.h>
65 #include <linux/kernel.h>
67 #include <linux/sched.h>
68 #include <linux/ptrace.h>
69 #include <linux/ctype.h>
70 #include <linux/string.h>
71 #include <linux/timer.h>
72 #include <linux/interrupt.h>
74 #include <linux/delay.h>
76 #include <linux/bitops.h>
77 #include <linux/pci.h>
78 #include <asm/system.h>
80 #include <linux/netdevice.h>
81 #include <linux/etherdevice.h>
82 #include <linux/skbuff.h>
83 #include <linux/if_arp.h>
84 #include <linux/ioport.h>
85 #include <linux/crc32.h>
86 #include <linux/phy.h>
88 #include "et1310_phy.h"
89 #include "et131x_adapter.h"
92 #define COUNTER_WRAP_16_BIT 0x10000
93 #define COUNTER_WRAP_12_BIT 0x1000
96 * et1310_config_mac_regs1 - Initialize the first part of MAC regs
97 * @adapter: pointer to our adapter structure
99 void et1310_config_mac_regs1(struct et131x_adapter
*adapter
)
101 struct mac_regs __iomem
*macregs
= &adapter
->regs
->mac
;
106 /* First we need to reset everything. Write to MAC configuration
107 * register 1 to perform reset.
109 writel(0xC00F0000, ¯egs
->cfg1
);
111 /* Next lets configure the MAC Inter-packet gap register */
112 ipg
= 0x38005860; /* IPG1 0x38 IPG2 0x58 B2B 0x60 */
113 ipg
|= 0x50 << 8; /* ifg enforce 0x50 */
114 writel(ipg
, ¯egs
->ipg
);
116 /* Next lets configure the MAC Half Duplex register */
117 /* BEB trunc 0xA, Ex Defer, Rexmit 0xF Coll 0x37 */
118 writel(0x00A1F037, ¯egs
->hfdp
);
120 /* Next lets configure the MAC Interface Control register */
121 writel(0, ¯egs
->if_ctrl
);
123 /* Let's move on to setting up the mii management configuration */
124 writel(0x07, ¯egs
->mii_mgmt_cfg
); /* Clock reset 0x7 */
126 /* Next lets configure the MAC Station Address register. These
127 * values are read from the EEPROM during initialization and stored
128 * in the adapter structure. We write what is stored in the adapter
129 * structure to the MAC Station Address registers high and low. This
130 * station address is used for generating and checking pause control
133 station2
= (adapter
->addr
[1] << ET_MAC_STATION_ADDR2_OC2_SHIFT
) |
134 (adapter
->addr
[0] << ET_MAC_STATION_ADDR2_OC1_SHIFT
);
135 station1
= (adapter
->addr
[5] << ET_MAC_STATION_ADDR1_OC6_SHIFT
) |
136 (adapter
->addr
[4] << ET_MAC_STATION_ADDR1_OC5_SHIFT
) |
137 (adapter
->addr
[3] << ET_MAC_STATION_ADDR1_OC4_SHIFT
) |
139 writel(station1
, ¯egs
->station_addr_1
);
140 writel(station2
, ¯egs
->station_addr_2
);
142 /* Max ethernet packet in bytes that will passed by the mac without
143 * being truncated. Allow the MAC to pass 4 more than our max packet
144 * size. This is 4 for the Ethernet CRC.
146 * Packets larger than (registry_jumbo_packet) that do not contain a
147 * VLAN ID will be dropped by the Rx function.
149 writel(adapter
->registry_jumbo_packet
+ 4, ¯egs
->max_fm_len
);
151 /* clear out MAC config reset */
152 writel(0, ¯egs
->cfg1
);
156 * et1310_config_mac_regs2 - Initialize the second part of MAC regs
157 * @adapter: pointer to our adapter structure
159 void et1310_config_mac_regs2(struct et131x_adapter
*adapter
)
162 struct mac_regs __iomem
*mac
= &adapter
->regs
->mac
;
163 struct phy_device
*phydev
= adapter
->phydev
;
169 ctl
= readl(&adapter
->regs
->txmac
.ctl
);
170 cfg1
= readl(&mac
->cfg1
);
171 cfg2
= readl(&mac
->cfg2
);
172 ifctrl
= readl(&mac
->if_ctrl
);
174 /* Set up the if mode bits */
176 if (phydev
&& phydev
->speed
== SPEED_1000
) {
179 ifctrl
&= ~(1 << 24);
185 /* We need to enable Rx/Tx */
186 cfg1
|= CFG1_RX_ENABLE
| CFG1_TX_ENABLE
| CFG1_TX_FLOW
;
187 /* Initialize loop back to off */
188 cfg1
&= ~(CFG1_LOOPBACK
| CFG1_RX_FLOW
);
189 if (adapter
->flowcontrol
== FLOW_RXONLY
||
190 adapter
->flowcontrol
== FLOW_BOTH
)
191 cfg1
|= CFG1_RX_FLOW
;
192 writel(cfg1
, &mac
->cfg1
);
194 /* Now we need to initialize the MAC Configuration 2 register */
195 /* preamble 7, check length, huge frame off, pad crc, crc enable
200 /* Turn on duplex if needed */
201 if (phydev
&& phydev
->duplex
== DUPLEX_FULL
)
204 ifctrl
&= ~(1 << 26);
205 if (phydev
&& phydev
->duplex
== DUPLEX_HALF
)
206 ifctrl
|= (1<<26); /* Enable ghd */
208 writel(ifctrl
, &mac
->if_ctrl
);
209 writel(cfg2
, &mac
->cfg2
);
214 cfg1
= readl(&mac
->cfg1
);
215 } while ((cfg1
& CFG1_WAIT
) != CFG1_WAIT
&& delay
< 100);
218 dev_warn(&adapter
->pdev
->dev
,
219 "Syncd bits did not respond correctly cfg1 word 0x%08x\n",
224 ctl
|= 0x09; /* TX mac enable, FC disable */
225 writel(ctl
, &adapter
->regs
->txmac
.ctl
);
227 /* Ready to start the RXDMA/TXDMA engine */
228 if (adapter
->flags
& fMP_ADAPTER_LOWER_POWER
) {
229 et131x_rx_dma_enable(adapter
);
230 et131x_tx_dma_enable(adapter
);
234 void et1310_config_rxmac_regs(struct et131x_adapter
*adapter
)
236 struct rxmac_regs __iomem
*rxmac
= &adapter
->regs
->rxmac
;
237 struct phy_device
*phydev
= adapter
->phydev
;
242 /* Disable the MAC while it is being configured (also disable WOL) */
243 writel(0x8, &rxmac
->ctrl
);
245 /* Initialize WOL to disabled. */
246 writel(0, &rxmac
->crc0
);
247 writel(0, &rxmac
->crc12
);
248 writel(0, &rxmac
->crc34
);
250 /* We need to set the WOL mask0 - mask4 next. We initialize it to
251 * its default Values of 0x00000000 because there are not WOL masks
254 writel(0, &rxmac
->mask0_word0
);
255 writel(0, &rxmac
->mask0_word1
);
256 writel(0, &rxmac
->mask0_word2
);
257 writel(0, &rxmac
->mask0_word3
);
259 writel(0, &rxmac
->mask1_word0
);
260 writel(0, &rxmac
->mask1_word1
);
261 writel(0, &rxmac
->mask1_word2
);
262 writel(0, &rxmac
->mask1_word3
);
264 writel(0, &rxmac
->mask2_word0
);
265 writel(0, &rxmac
->mask2_word1
);
266 writel(0, &rxmac
->mask2_word2
);
267 writel(0, &rxmac
->mask2_word3
);
269 writel(0, &rxmac
->mask3_word0
);
270 writel(0, &rxmac
->mask3_word1
);
271 writel(0, &rxmac
->mask3_word2
);
272 writel(0, &rxmac
->mask3_word3
);
274 writel(0, &rxmac
->mask4_word0
);
275 writel(0, &rxmac
->mask4_word1
);
276 writel(0, &rxmac
->mask4_word2
);
277 writel(0, &rxmac
->mask4_word3
);
279 /* Lets setup the WOL Source Address */
280 sa_lo
= (adapter
->addr
[2] << ET_WOL_LO_SA3_SHIFT
) |
281 (adapter
->addr
[3] << ET_WOL_LO_SA4_SHIFT
) |
282 (adapter
->addr
[4] << ET_WOL_LO_SA5_SHIFT
) |
284 writel(sa_lo
, &rxmac
->sa_lo
);
286 sa_hi
= (u32
) (adapter
->addr
[0] << ET_WOL_HI_SA1_SHIFT
) |
288 writel(sa_hi
, &rxmac
->sa_hi
);
290 /* Disable all Packet Filtering */
291 writel(0, &rxmac
->pf_ctrl
);
293 /* Let's initialize the Unicast Packet filtering address */
294 if (adapter
->packet_filter
& ET131X_PACKET_TYPE_DIRECTED
) {
295 et1310_setup_device_for_unicast(adapter
);
296 pf_ctrl
|= 4; /* Unicast filter */
298 writel(0, &rxmac
->uni_pf_addr1
);
299 writel(0, &rxmac
->uni_pf_addr2
);
300 writel(0, &rxmac
->uni_pf_addr3
);
303 /* Let's initialize the Multicast hash */
304 if (!(adapter
->packet_filter
& ET131X_PACKET_TYPE_ALL_MULTICAST
)) {
305 pf_ctrl
|= 2; /* Multicast filter */
306 et1310_setup_device_for_multicast(adapter
);
309 /* Runt packet filtering. Didn't work in version A silicon. */
310 pf_ctrl
|= (NIC_MIN_PACKET_SIZE
+ 4) << 16;
311 pf_ctrl
|= 8; /* Fragment filter */
313 if (adapter
->registry_jumbo_packet
> 8192)
314 /* In order to transmit jumbo packets greater than 8k, the
315 * FIFO between RxMAC and RxDMA needs to be reduced in size
316 * to (16k - Jumbo packet size). In order to implement this,
317 * we must use "cut through" mode in the RxMAC, which chops
318 * packets down into segments which are (max_size * 16). In
319 * this case we selected 256 bytes, since this is the size of
320 * the PCI-Express TLP's that the 1310 uses.
322 * seg_en on, fc_en off, size 0x10
324 writel(0x41, &rxmac
->mcif_ctrl_max_seg
);
326 writel(0, &rxmac
->mcif_ctrl_max_seg
);
328 /* Initialize the MCIF water marks */
329 writel(0, &rxmac
->mcif_water_mark
);
331 /* Initialize the MIF control */
332 writel(0, &rxmac
->mif_ctrl
);
334 /* Initialize the Space Available Register */
335 writel(0, &rxmac
->space_avail
);
337 /* Initialize the the mif_ctrl register
338 * bit 3: Receive code error. One or more nibbles were signaled as
339 * errors during the reception of the packet. Clear this
340 * bit in Gigabit, set it in 100Mbit. This was derived
341 * experimentally at UNH.
342 * bit 4: Receive CRC error. The packet's CRC did not match the
343 * internally generated CRC.
344 * bit 5: Receive length check error. Indicates that frame length
345 * field value in the packet does not match the actual data
346 * byte length and is not a type field.
347 * bit 16: Receive frame truncated.
348 * bit 17: Drop packet enable
350 if (phydev
&& phydev
->speed
== SPEED_100
)
351 writel(0x30038, &rxmac
->mif_ctrl
);
353 writel(0x30030, &rxmac
->mif_ctrl
);
355 /* Finally we initialize RxMac to be enabled & WOL disabled. Packet
356 * filter is always enabled since it is where the runt packets are
357 * supposed to be dropped. For version A silicon, runt packet
358 * dropping doesn't work, so it is disabled in the pf_ctrl register,
359 * but we still leave the packet filter on.
361 writel(pf_ctrl
, &rxmac
->pf_ctrl
);
362 writel(0x9, &rxmac
->ctrl
);
365 void et1310_config_txmac_regs(struct et131x_adapter
*adapter
)
367 struct txmac_regs __iomem
*txmac
= &adapter
->regs
->txmac
;
369 /* We need to update the Control Frame Parameters
370 * cfpt - control frame pause timer set to 64 (0x40)
371 * cfep - control frame extended pause timer set to 0x0
373 if (adapter
->flowcontrol
== FLOW_NONE
)
374 writel(0, &txmac
->cf_param
);
376 writel(0x40, &txmac
->cf_param
);
379 void et1310_config_macstat_regs(struct et131x_adapter
*adapter
)
381 struct macstat_regs __iomem
*macstat
=
382 &adapter
->regs
->macstat
;
384 /* Next we need to initialize all the macstat registers to zero on
387 writel(0, &macstat
->txrx_0_64_byte_frames
);
388 writel(0, &macstat
->txrx_65_127_byte_frames
);
389 writel(0, &macstat
->txrx_128_255_byte_frames
);
390 writel(0, &macstat
->txrx_256_511_byte_frames
);
391 writel(0, &macstat
->txrx_512_1023_byte_frames
);
392 writel(0, &macstat
->txrx_1024_1518_byte_frames
);
393 writel(0, &macstat
->txrx_1519_1522_gvln_frames
);
395 writel(0, &macstat
->rx_bytes
);
396 writel(0, &macstat
->rx_packets
);
397 writel(0, &macstat
->rx_fcs_errs
);
398 writel(0, &macstat
->rx_multicast_packets
);
399 writel(0, &macstat
->rx_broadcast_packets
);
400 writel(0, &macstat
->rx_control_frames
);
401 writel(0, &macstat
->rx_pause_frames
);
402 writel(0, &macstat
->rx_unknown_opcodes
);
403 writel(0, &macstat
->rx_align_errs
);
404 writel(0, &macstat
->rx_frame_len_errs
);
405 writel(0, &macstat
->rx_code_errs
);
406 writel(0, &macstat
->rx_carrier_sense_errs
);
407 writel(0, &macstat
->rx_undersize_packets
);
408 writel(0, &macstat
->rx_oversize_packets
);
409 writel(0, &macstat
->rx_fragment_packets
);
410 writel(0, &macstat
->rx_jabbers
);
411 writel(0, &macstat
->rx_drops
);
413 writel(0, &macstat
->tx_bytes
);
414 writel(0, &macstat
->tx_packets
);
415 writel(0, &macstat
->tx_multicast_packets
);
416 writel(0, &macstat
->tx_broadcast_packets
);
417 writel(0, &macstat
->tx_pause_frames
);
418 writel(0, &macstat
->tx_deferred
);
419 writel(0, &macstat
->tx_excessive_deferred
);
420 writel(0, &macstat
->tx_single_collisions
);
421 writel(0, &macstat
->tx_multiple_collisions
);
422 writel(0, &macstat
->tx_late_collisions
);
423 writel(0, &macstat
->tx_excessive_collisions
);
424 writel(0, &macstat
->tx_total_collisions
);
425 writel(0, &macstat
->tx_pause_honored_frames
);
426 writel(0, &macstat
->tx_drops
);
427 writel(0, &macstat
->tx_jabbers
);
428 writel(0, &macstat
->tx_fcs_errs
);
429 writel(0, &macstat
->tx_control_frames
);
430 writel(0, &macstat
->tx_oversize_frames
);
431 writel(0, &macstat
->tx_undersize_frames
);
432 writel(0, &macstat
->tx_fragments
);
433 writel(0, &macstat
->carry_reg1
);
434 writel(0, &macstat
->carry_reg2
);
436 /* Unmask any counters that we want to track the overflow of.
437 * Initially this will be all counters. It may become clear later
438 * that we do not need to track all counters.
440 writel(0xFFFFBE32, &macstat
->carry_reg1_mask
);
441 writel(0xFFFE7E8B, &macstat
->carry_reg2_mask
);
444 void et1310_config_flow_control(struct et131x_adapter
*adapter
)
446 struct phy_device
*phydev
= adapter
->phydev
;
448 if (phydev
->duplex
== DUPLEX_HALF
) {
449 adapter
->flowcontrol
= FLOW_NONE
;
451 char remote_pause
, remote_async_pause
;
453 et1310_phy_access_mii_bit(adapter
,
454 TRUEPHY_BIT_READ
, 5, 10, &remote_pause
);
455 et1310_phy_access_mii_bit(adapter
,
456 TRUEPHY_BIT_READ
, 5, 11,
457 &remote_async_pause
);
459 if ((remote_pause
== TRUEPHY_BIT_SET
) &&
460 (remote_async_pause
== TRUEPHY_BIT_SET
)) {
461 adapter
->flowcontrol
= adapter
->wanted_flow
;
462 } else if ((remote_pause
== TRUEPHY_BIT_SET
) &&
463 (remote_async_pause
== TRUEPHY_BIT_CLEAR
)) {
464 if (adapter
->wanted_flow
== FLOW_BOTH
)
465 adapter
->flowcontrol
= FLOW_BOTH
;
467 adapter
->flowcontrol
= FLOW_NONE
;
468 } else if ((remote_pause
== TRUEPHY_BIT_CLEAR
) &&
469 (remote_async_pause
== TRUEPHY_BIT_CLEAR
)) {
470 adapter
->flowcontrol
= FLOW_NONE
;
471 } else {/* if (remote_pause == TRUEPHY_CLEAR_BIT &&
472 remote_async_pause == TRUEPHY_SET_BIT) */
473 if (adapter
->wanted_flow
== FLOW_BOTH
)
474 adapter
->flowcontrol
= FLOW_RXONLY
;
476 adapter
->flowcontrol
= FLOW_NONE
;
482 * et1310_update_macstat_host_counters - Update the local copy of the statistics
483 * @adapter: pointer to the adapter structure
485 void et1310_update_macstat_host_counters(struct et131x_adapter
*adapter
)
487 struct ce_stats
*stats
= &adapter
->stats
;
488 struct macstat_regs __iomem
*macstat
=
489 &adapter
->regs
->macstat
;
491 stats
->tx_collisions
+= readl(&macstat
->tx_total_collisions
);
492 stats
->tx_first_collisions
+= readl(&macstat
->tx_single_collisions
);
493 stats
->tx_deferred
+= readl(&macstat
->tx_deferred
);
494 stats
->tx_excessive_collisions
+=
495 readl(&macstat
->tx_multiple_collisions
);
496 stats
->tx_late_collisions
+= readl(&macstat
->tx_late_collisions
);
497 stats
->tx_underflows
+= readl(&macstat
->tx_undersize_frames
);
498 stats
->tx_max_pkt_errs
+= readl(&macstat
->tx_oversize_frames
);
500 stats
->rx_align_errs
+= readl(&macstat
->rx_align_errs
);
501 stats
->rx_crc_errs
+= readl(&macstat
->rx_code_errs
);
502 stats
->rcvd_pkts_dropped
+= readl(&macstat
->rx_drops
);
503 stats
->rx_overflows
+= readl(&macstat
->rx_oversize_packets
);
504 stats
->rx_code_violations
+= readl(&macstat
->rx_fcs_errs
);
505 stats
->rx_length_errs
+= readl(&macstat
->rx_frame_len_errs
);
506 stats
->rx_other_errs
+= readl(&macstat
->rx_fragment_packets
);
510 * et1310_handle_macstat_interrupt
511 * @adapter: pointer to the adapter structure
513 * One of the MACSTAT counters has wrapped. Update the local copy of
514 * the statistics held in the adapter structure, checking the "wrap"
515 * bit for each counter.
517 void et1310_handle_macstat_interrupt(struct et131x_adapter
*adapter
)
522 /* Read the interrupt bits from the register(s). These are Clear On
525 carry_reg1
= readl(&adapter
->regs
->macstat
.carry_reg1
);
526 carry_reg2
= readl(&adapter
->regs
->macstat
.carry_reg2
);
528 writel(carry_reg1
, &adapter
->regs
->macstat
.carry_reg1
);
529 writel(carry_reg2
, &adapter
->regs
->macstat
.carry_reg2
);
531 /* We need to do update the host copy of all the MAC_STAT counters.
532 * For each counter, check it's overflow bit. If the overflow bit is
533 * set, then increment the host version of the count by one complete
534 * revolution of the counter. This routine is called when the counter
535 * block indicates that one of the counters has wrapped.
537 if (carry_reg1
& (1 << 14))
538 adapter
->stats
.rx_code_violations
+= COUNTER_WRAP_16_BIT
;
539 if (carry_reg1
& (1 << 8))
540 adapter
->stats
.rx_align_errs
+= COUNTER_WRAP_12_BIT
;
541 if (carry_reg1
& (1 << 7))
542 adapter
->stats
.rx_length_errs
+= COUNTER_WRAP_16_BIT
;
543 if (carry_reg1
& (1 << 2))
544 adapter
->stats
.rx_other_errs
+= COUNTER_WRAP_16_BIT
;
545 if (carry_reg1
& (1 << 6))
546 adapter
->stats
.rx_crc_errs
+= COUNTER_WRAP_16_BIT
;
547 if (carry_reg1
& (1 << 3))
548 adapter
->stats
.rx_overflows
+= COUNTER_WRAP_16_BIT
;
549 if (carry_reg1
& (1 << 0))
550 adapter
->stats
.rcvd_pkts_dropped
+= COUNTER_WRAP_16_BIT
;
551 if (carry_reg2
& (1 << 16))
552 adapter
->stats
.tx_max_pkt_errs
+= COUNTER_WRAP_12_BIT
;
553 if (carry_reg2
& (1 << 15))
554 adapter
->stats
.tx_underflows
+= COUNTER_WRAP_12_BIT
;
555 if (carry_reg2
& (1 << 6))
556 adapter
->stats
.tx_first_collisions
+= COUNTER_WRAP_12_BIT
;
557 if (carry_reg2
& (1 << 8))
558 adapter
->stats
.tx_deferred
+= COUNTER_WRAP_12_BIT
;
559 if (carry_reg2
& (1 << 5))
560 adapter
->stats
.tx_excessive_collisions
+= COUNTER_WRAP_12_BIT
;
561 if (carry_reg2
& (1 << 4))
562 adapter
->stats
.tx_late_collisions
+= COUNTER_WRAP_12_BIT
;
563 if (carry_reg2
& (1 << 2))
564 adapter
->stats
.tx_collisions
+= COUNTER_WRAP_12_BIT
;
567 void et1310_setup_device_for_multicast(struct et131x_adapter
*adapter
)
569 struct rxmac_regs __iomem
*rxmac
= &adapter
->regs
->rxmac
;
578 /* If ET131X_PACKET_TYPE_MULTICAST is specified, then we provision
579 * the multi-cast LIST. If it is NOT specified, (and "ALL" is not
580 * specified) then we should pass NO multi-cast addresses to the
583 if (adapter
->packet_filter
& ET131X_PACKET_TYPE_MULTICAST
) {
584 /* Loop through our multicast array and set up the device */
585 for (nIndex
= 0; nIndex
< adapter
->multicast_addr_count
;
587 result
= ether_crc(6, adapter
->multicast_list
[nIndex
]);
589 result
= (result
& 0x3F800000) >> 23;
592 hash1
|= (1 << result
);
593 } else if ((31 < result
) && (result
< 64)) {
595 hash2
|= (1 << result
);
596 } else if ((63 < result
) && (result
< 96)) {
598 hash3
|= (1 << result
);
601 hash4
|= (1 << result
);
606 /* Write out the new hash to the device */
607 pm_csr
= readl(&adapter
->regs
->global
.pm_csr
);
608 if (!et1310_in_phy_coma(adapter
)) {
609 writel(hash1
, &rxmac
->multi_hash1
);
610 writel(hash2
, &rxmac
->multi_hash2
);
611 writel(hash3
, &rxmac
->multi_hash3
);
612 writel(hash4
, &rxmac
->multi_hash4
);
616 void et1310_setup_device_for_unicast(struct et131x_adapter
*adapter
)
618 struct rxmac_regs __iomem
*rxmac
= &adapter
->regs
->rxmac
;
624 /* Set up unicast packet filter reg 3 to be the first two octets of
625 * the MAC address for both address
627 * Set up unicast packet filter reg 2 to be the octets 2 - 5 of the
628 * MAC address for second address
630 * Set up unicast packet filter reg 3 to be the octets 2 - 5 of the
631 * MAC address for first address
633 uni_pf3
= (adapter
->addr
[0] << ET_UNI_PF_ADDR2_1_SHIFT
) |
634 (adapter
->addr
[1] << ET_UNI_PF_ADDR2_2_SHIFT
) |
635 (adapter
->addr
[0] << ET_UNI_PF_ADDR1_1_SHIFT
) |
638 uni_pf2
= (adapter
->addr
[2] << ET_UNI_PF_ADDR2_3_SHIFT
) |
639 (adapter
->addr
[3] << ET_UNI_PF_ADDR2_4_SHIFT
) |
640 (adapter
->addr
[4] << ET_UNI_PF_ADDR2_5_SHIFT
) |
643 uni_pf1
= (adapter
->addr
[2] << ET_UNI_PF_ADDR1_3_SHIFT
) |
644 (adapter
->addr
[3] << ET_UNI_PF_ADDR1_4_SHIFT
) |
645 (adapter
->addr
[4] << ET_UNI_PF_ADDR1_5_SHIFT
) |
648 pm_csr
= readl(&adapter
->regs
->global
.pm_csr
);
649 if (!et1310_in_phy_coma(adapter
)) {
650 writel(uni_pf1
, &rxmac
->uni_pf_addr1
);
651 writel(uni_pf2
, &rxmac
->uni_pf_addr2
);
652 writel(uni_pf3
, &rxmac
->uni_pf_addr3
);