9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 #include <aros/debug.h>
29 //#define RTL_DEBUG_PACKET
33 if (unit->rtl8168u_flags & IFF_DEBUG) \
38 #if defined(RTL_DEBUG_PACKET)
40 if (unit->rtl8168u_flags & IFF_DEBUG) \
48 //#define HAVE__PCI_MWI
50 #include <exec/types.h>
51 #include <exec/libraries.h>
52 #include <exec/semaphores.h>
53 #include <exec/devices.h>
54 #include <exec/interrupts.h>
61 #include <devices/timer.h>
62 #include <devices/sana2.h>
63 #include <devices/sana2specialstats.h>
65 #include <proto/exec.h>
67 #include LC_LIBDEFS_FILE
69 #define net_device RTL8168Unit
71 #define RTL8168_TASK_NAME "%s.task"
72 #define RTL8168_PORT_NAME "%s.port"
74 /** Operational parameters that are set at compile time **/
75 #define ETH_ZLEN 60 // Min. octets in frame sans FCS
77 // Maximum size of the in-memory receive ring (smaller if no memory)
78 #define RX_FIFO_THRESH 4 // Rx buffer level before first PCI xfer
80 // Size of the Tx bounce buffers -- must be at least (mtu+14+4)
81 #define TX_BUF_SIZE 1536
82 #define TX_FIFO_THRESH 256 // In bytes, rounded down to 32 byte units
83 #define TX_DMA_BURST 4 // Calculate as 16 << val
85 /** Device Driver Structures **/
87 extern struct Library
*OOPBase
;
90 struct Device rtl8168b_Device
;
92 OOP_Object
*rtl8168b_PCI
;
93 OOP_AttrBase rtl8168b_PCIDeviceAttrBase
;
95 ULONG rtl8168b_UnitCount
;
96 struct List rtl8168b_Units
;
98 /* TODO: move into a config block */
99 /* Maximum events (Rx packets, etc.) to handle at each interrupt. */
100 int rtl8168b_MaxIntWork
;
102 /* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
103 The RTL chips use a 64 element hash table based on the Ethernet CRC. */
104 int rtl8168b_MulticastFilterLimit
;
108 int speed
[MAX_UNITS
];
109 int duplex
[MAX_UNITS
];
110 int autoneg
[MAX_UNITS
];
113 #undef HiddPCIDeviceAttrBase
114 #define HiddPCIDeviceAttrBase (LIBBASE->rtl8168b_PCIDeviceAttrBase)
116 struct RTL8168Startup
118 struct MsgPort
*rtl8168sm_SyncPort
;
119 struct RTL8168Unit
*rtl8168sm_Unit
;
133 struct MsgPort read_port
;
134 BOOL (*rx_function
)(APTR
, APTR
, ULONG
);
135 BOOL (*tx_function
)(APTR
, APTR
, ULONG
);
136 struct Hook
*filter_hook
;
137 struct MinList initial_stats
;
144 struct Sana2PacketTypeStats stats
;
152 struct Sana2PacketTypeStats stats
;
161 ULONG lower_bound_left
;
162 ULONG upper_bound_left
;
163 UWORD lower_bound_right
;
164 UWORD upper_bound_right
;
170 struct MinNode rtl8168u_Node
;
172 struct RTL8168Base
*rtl8168u_device
;
174 STRPTR rtl8168u_name
;
176 ULONG rtl8168u_UnitNum
;
177 IPTR rtl8168u_DriverFlags
;
179 OOP_Object
*rtl8168u_PCIDevice
;
180 OOP_Object
*rtl8168u_PCIDriver
;
183 int rtl8168u_open_count
;
184 struct SignalSemaphore rtl8168u_unit_lock
;
186 LONG rtl8168u_range_count
;
187 struct MinList rtl8168u_Openers
;
188 struct MinList rtl8168u_multicast_ranges
;
189 struct MinList rtl8168u_type_trackers
;
191 struct timeval rtl8168u_toutPOLL
;
192 BOOL rtl8168u_toutNEED
;
193 BOOL rtl8168u_IntsAdded
;
195 struct MsgPort
*rtl8168u_TimerSlowPort
;
196 struct timerequest
*rtl8168u_TimerSlowReq
;
198 struct MsgPort
*rtl8168u_TimerFastPort
;
199 struct timerequest
*rtl8168u_TimerFastReq
;
201 struct MsgPort rtl8168u_DelayPort
;
202 struct timerequest rtl8168u_DelayReq
;
205 ULONG rtl8168u_flags
;
206 struct Sana2DeviceQuery rtl8168u_Sana2Info
;
207 struct Sana2DeviceStats rtl8168u_stats
;
208 ULONG rtl8168u_special_stats
[STAT_COUNT
];
210 char *rtl8168u_rtl_cardname
;
211 const char *rtl8168u_rtl_chipname
;
212 ULONG rtl8168u_rtl_chipcapabilities
;
214 ULONG rtl8168u_rtl_LinkSpeed
;
215 #define support_fdx (1 << 0) // Supports Full Duplex
216 #define support_mii (1 << 1)
217 #define support_fset (1 << 2)
218 #define support_ltint (1 << 3)
219 #define support_dxsuflo (1 << 4)
221 void (*initialize
)(struct RTL8168Unit
*);
222 void (*deinitialize
)(struct RTL8168Unit
*);
223 int (*start
)(struct RTL8168Unit
*);
224 int (*stop
)(struct RTL8168Unit
*);
225 int (*alloc_rx
)(struct RTL8168Unit
*);
226 void (*set_mac_address
)(struct RTL8168Unit
*);
227 void (*linkchange
)(struct RTL8168Unit
*);
228 void (*linkirq
)(struct RTL8168Unit
*);
229 // ULONG (*descr_getlength)(struct ring_desc *prd, ULONG v);
230 void (*set_multicast
)(struct RTL8168Unit
*);
232 struct Process
*rtl8168u_Process
;
234 struct Interrupt rtl8168u_irqhandler
;
235 struct Interrupt rtl8168u_touthandler
;
236 IPTR rtl8168u_DeviceID
;
237 APTR rtl8168u_BaseMem
;
238 IPTR rtl8168u_SizeMem
;
239 APTR rtl8168u_BaseIO
;
241 BYTE rtl8168u_signal_0
;
242 BYTE rtl8168u_signal_1
;
243 BYTE rtl8168u_signal_2
;
244 BYTE rtl8168u_signal_3
;
246 struct MsgPort
*rtl8168u_input_port
;
248 struct MsgPort
*rtl8168u_request_ports
[REQUEST_QUEUE_COUNT
];
250 struct Interrupt rtl8168u_rx_int
;
251 struct Interrupt rtl8168u_tx_int
;
253 ULONG rtl8168u_state
;
254 APTR rtl8168u_mc_list
;
255 int rtl8168u_mc_count
;
257 UBYTE rtl8168u_dev_addr
[6];
258 UBYTE rtl8168u_org_addr
[6];
259 struct rtl8168_priv
*rtl8168u_priv
;
261 UWORD rtl8168u_intr_mask
;
264 void handle_request(LIBBASETYPEPTR
, struct IOSana2Req
*);
266 /* Media selection options. */
277 /* Standard interface flags (netdevice->flags). */
278 #define IFF_UP 0x1 /* interface is up */
279 #define IFF_BROADCAST 0x2 /* broadcast address valid */
280 #define IFF_DEBUG 0x4 /* turn on debugging */
281 #define IFF_LOOPBACK 0x8 /* is a loopback net */
282 #define IFF_POINTOPOINT 0x10 /* interface is has p-p link */
283 #define IFF_NOTRAILERS 0x20 /* avoid use of trailers */
284 #define IFF_RUNNING 0x40 /* resources allocated */
285 #define IFF_NOARP 0x80 /* no ARP protocol */
286 #define IFF_PROMISC 0x100 /* receive all packets */
287 #define IFF_ALLMULTI 0x200 /* receive all multicast packets*/
289 #define IFF_MASTER 0x400 /* master of a load balancer */
290 #define IFF_SLAVE 0x800 /* slave of a load balancer */
292 #define IFF_MULTICAST 0x1000 /* Supports multicast */
294 #define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_MASTER|IFF_SLAVE|IFF_RUNNING)
296 #define IFF_PORTSEL 0x2000 /* can set media type */
297 #define IFF_AUTOMEDIA 0x4000 /* auto media select active */
298 #define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses*/
299 #define IFF_SHARED 0x10000 /* interface may be shared */
300 #define IFF_CONFIGURED 0x20000 /* interface already configured */
302 /* These flag bits are private to the generic network queueing
303 * layer, they may not be explicitly referenced by any other
311 __LINK_STATE_PRESENT
,
313 __LINK_STATE_NOCARRIER
,
314 __LINK_STATE_RX_SCHED
,
315 __LINK_STATE_LINKWATCH_PENDING
318 static inline int test_bit(int nr
, const volatile ULONG
*addr
)
320 return ((1UL << (nr
& 31)) & (addr
[nr
>> 5])) != 0;
323 static inline void set_bit(int nr
, volatile ULONG
*addr
)
325 addr
[nr
>> 5] |= 1UL << (nr
& 31);
328 static inline void clear_bit(int nr
, volatile ULONG
*addr
)
330 addr
[nr
>> 5] &= ~(1UL << (nr
& 31));
333 static inline int test_and_set_bit(int nr
, volatile ULONG
*addr
)
335 int oldbit
= test_bit(nr
, addr
);
340 static inline int test_and_clear_bit(int nr
, volatile ULONG
*addr
)
342 int oldbit
= test_bit(nr
, addr
);
347 static inline void netif_schedule(struct RTL8168Unit
*unit
)
349 if (!test_bit(__LINK_STATE_XOFF
, &unit
->rtl8168u_state
)) {
350 Cause(&unit
->rtl8168u_tx_int
);
354 static inline void netif_start_queue(struct RTL8168Unit
*unit
)
356 clear_bit(__LINK_STATE_XOFF
, &unit
->rtl8168u_state
);
359 static inline void netif_wake_queue(struct RTL8168Unit
*unit
)
361 if (test_and_clear_bit(__LINK_STATE_XOFF
, &unit
->rtl8168u_state
)) {
362 Cause(&unit
->rtl8168u_tx_int
);
366 static inline void netif_stop_queue(struct RTL8168Unit
*unit
)
368 set_bit(__LINK_STATE_XOFF
, &unit
->rtl8168u_state
);
371 static inline int netif_queue_stopped(const struct RTL8168Unit
*unit
)
373 return test_bit(__LINK_STATE_XOFF
, &unit
->rtl8168u_state
);
376 static inline int netif_running(const struct RTL8168Unit
*unit
)
378 return test_bit(__LINK_STATE_START
, &unit
->rtl8168u_state
);
381 static inline int netif_carrier_ok(const struct RTL8168Unit
*unit
)
383 return !test_bit(__LINK_STATE_NOCARRIER
, &unit
->rtl8168u_state
);
386 extern VOID
ReportEvents(struct RTL8168Base
*, struct RTL8168Unit
*, ULONG
);
388 static inline void netif_carrier_on(struct RTL8168Unit
*unit
)
390 if (test_and_clear_bit(__LINK_STATE_NOCARRIER
, &unit
->rtl8168u_state
)) {
391 unit
->rtl8168u_flags
|= IFF_UP
;
392 RTLD(bug("[%s] %s: Device set as ONLINE\n",unit
->rtl8168u_name
, __PRETTY_FUNCTION__
))
393 ReportEvents(unit
->rtl8168u_device
, unit
, S2EVENT_ONLINE
);
397 static inline void netif_carrier_off(struct RTL8168Unit
*unit
)
399 if (!test_and_set_bit(__LINK_STATE_NOCARRIER
, &unit
->rtl8168u_state
)) {
400 unit
->rtl8168u_flags
&= ~IFF_UP
;
401 RTLD(bug("[%s] %s: Device set as OFFLINE\n",unit
->rtl8168u_name
, __PRETTY_FUNCTION__
))
402 ReportEvents(unit
->rtl8168u_device
, unit
, S2EVENT_OFFLINE
);
407 * We tag multicasts with these structures.
410 #define MAX_ADDR_LEN 32
414 struct dev_mc_list
*next
;
415 UBYTE dmi_addr
[MAX_ADDR_LEN
];
416 unsigned char dmi_addrlen
;
421 struct pci_resource
{
435 struct rtl8168_priv
{
436 struct RTL8168Unit
*pci_dev
;
445 int phy_auto_nego_reg
;
446 int phy_1000_ctrl_reg
;
452 struct TxDesc
*TxDescArray
; /* 256-aligned Tx descriptor ring */
453 struct RxDesc
*RxDescArray
; /* 256-aligned Rx descriptor ring */
457 unsigned int rtl8168_rx_config
;
461 int rx_fifo_overflow
;
463 ULONG tx_tcp_csum_cmd
;
464 ULONG tx_udp_csum_cmd
;
465 ULONG tx_ip_csum_cmd
;
467 struct pci_resource pci_cfg_space
;
469 unsigned int pci_cfg_is_read
;
471 ULONG cur_rx
; /* Index into the Rx descriptor buffer of next Rx pkt. */
472 ULONG cur_tx
; /* Index into the Tx descriptor buffer of next Rx pkt. */
476 struct SignalSemaphore lock
;
481 #define pci_name(unit) (unit->rtl8168u_name)
486 #define ETH_DATA_LEN 1500
488 #define ETH_ADDRESSSIZE 6
489 #define ETH_HEADERSIZE 14
490 #define ETH_CRCSIZE 4
491 #define ETH_MTU (ETH_DATA_LEN)
492 #define ETH_MAXPACKETSIZE ((ETH_HEADERSIZE) + (ETH_MTU) + (ETH_CRCSIZE))
494 #define ETH_PACKET_DEST 0
495 #define ETH_PACKET_SOURCE 6
496 #define ETH_PACKET_TYPE 12
497 #define ETH_PACKET_IEEELEN 12
498 #define ETH_PACKET_SNAPTYPE 20
499 #define ETH_PACKET_DATA 14
500 #define ETH_PACKET_CRC (ETH_PACKET_DATA + ETH_MTU)
502 #define RXTX_ALLOC_BUFSIZE (ETH_MAXPACKETSIZE + 26)
504 #define TX_LIMIT_STOP 63
505 #define TX_LIMIT_START 62
508 UBYTE eth_packet_dest
[6];
509 UBYTE eth_packet_source
[6];
510 UWORD eth_packet_type
;
511 UBYTE eth_packet_data
[ETH_MTU
];
512 UBYTE eth_packet_crc
[4];
513 UBYTE eth_pad
[RXTX_ALLOC_BUFSIZE
- ETH_MAXPACKETSIZE
];
514 } __attribute__((packed
));
515 #define eth_packet_ieeelen eth_packet_type
517 /* ***************************** */
518 /* RTL8168 DEFINES */
519 /* ***************************** */
521 #ifndef DMA_64BIT_MASK
522 #define DMA_64BIT_MASK 0xffffffffffffffffULL
524 #ifndef DMA_32BIT_MASK
525 #define DMA_32BIT_MASK 0x00000000ffffffffULL
529 #define PCI_COMMAND 0x04
531 #ifndef PCI_CACHE_LINE_SIZE
532 #define PCI_CACHE_LINE_SIZE 0x0c
534 #ifndef PCI_LATENCY_TIMER
535 #define PCI_LATENCY_TIMER 0x0d
537 #ifndef PCI_BASE_ADDRESS_0
538 #define PCI_BASE_ADDRESS_0 0x10
540 #ifndef PCI_BASE_ADDRESS_2
541 #define PCI_BASE_ADDRESS_2 0x18
543 #ifndef PCI_BASE_ADDRESS_4
544 #define PCI_BASE_ADDRESS_4 0x20
546 #ifndef PCI_BASE_ADDRESS_5
547 #define PCI_BASE_ADDRESS_5 0x24
549 #ifndef PCI_INTERRUPT_LINE
550 #define PCI_INTERRUPT_LINE 0x32
554 #define ETH_ALEN ETH_ADDRESSSIZE
557 #define ETH_HLEN ETH_HEADERSIZE
560 #ifndef ADVERTISED_Pause
561 #define ADVERTISED_Pause (1 << 13)
563 #ifndef ADVERTISED_Asym_Pause
564 #define ADVERTISED_Asym_Pause (1 << 14)
566 #ifndef ADVERTISE_PAUSE_CAP
567 #define ADVERTISE_PAUSE_CAP 0x400
569 #ifndef ADVERTISE_PAUSE_ASYM
570 #define ADVERTISE_PAUSE_ASYM 0x800
573 #define MII_CTRL1000 0x09
575 #ifndef ADVERTISE_1000FULL
576 #define ADVERTISE_1000FULL 0x200
578 #ifndef ADVERTISE_1000HALF
579 #define ADVERTISE_1000HALF 0x100
582 /** Generic MII Registers - TODO: should be in MII header file **/
585 // Basic Mode Control Register
586 #define MII_BMCR 0x00
588 #ifndef MII_ADVERTISE
589 // Advertisement Control Register
590 #define MII_ADVERTISE 0x04
593 /** Basic Mode Control Register - TODO: should be in MII header file **/
595 #ifndef BMCR_FULLDPLX
597 #define BMCR_FULLDPLX 0x0100
599 #ifndef BMCR_ANRESTART
601 #define BMCR_ANRESTART 0x0200
603 #ifndef BMCR_ANENABLE
605 #define BMCR_ANENABLE 0x1000
608 #define BMCR_RESET 0x8000
611 /** Advertisement Control Register - TODO: should be in MII header file **/
613 #ifndef ADVERTISE_10HALF
614 #define ADVERTISE_10HALF 0x0020
616 #ifndef ADVERTISE_10FULL
617 #define ADVERTISE_10FULL 0x0040
619 #ifndef ADVERTISE_100HALF
620 #define ADVERTISE_100HALF 0x0080
622 #ifndef ADVERTISE_100FULL
623 #define ADVERTISE_100FULL 0x0100
626 /* These should also have an own header */
628 #ifndef AUTONEG_DISABLE
629 #define AUTONEG_DISABLE 0x00
631 #ifndef AUTONEG_ENABLE
632 #define AUTONEG_ENABLE 0x01
638 #define SPEED_100 100
641 #define SPEED_1000 1000
644 #define DUPLEX_HALF 0x00
647 #define DUPLEX_FULL 0x01
650 /* write/read MMIO register */
651 #define RTL_R8(addr) (*((volatile UBYTE *)(addr)))
652 #define RTL_R16(addr) (*((volatile UWORD *)(addr)))
653 #define RTL_R32(addr) (*((volatile ULONG *)(addr)))
654 #define RTL_W8(addr, val8) MMIO_W8(addr, val8)
655 #define RTL_W16(addr, val16) MMIO_W16(addr, val16)
656 #define RTL_W32(addr, val32) MMIO_W32(addr, val32)
658 #define R8168_REGS_SIZE 256
660 #define MAC_ADDR_LEN 6
662 #define Reserved2_data 7
663 #define RX_DMA_BURST 7 /* Maximum PCI burst, '6' is 1024 */
664 #define TX_DMA_BURST_unlimited 7
665 #define TX_DMA_BURST_1024 6
666 #define TX_DMA_BURST_512 5
667 #define TX_DMA_BURST_256 4
668 #define TX_DMA_BURST_128 3
669 #define TX_DMA_BURST_64 2
670 #define TX_DMA_BURST_32 1
671 #define TX_DMA_BURST_16 0
672 #define Reserved1_data 0x3F
673 #define RxPacketMaxSize 0x3FE8 /* 16K - 1 - ETH_HLEN - VLAN - CRC... */
674 #define Jumbo_Frame_2k (2 * 1024)
675 #define Jumbo_Frame_3k (3 * 1024)
676 #define Jumbo_Frame_4k (4 * 1024)
677 #define Jumbo_Frame_5k (5 * 1024)
678 #define Jumbo_Frame_6k (6 * 1024)
679 #define Jumbo_Frame_7k (7 * 1024)
680 #define Jumbo_Frame_8k (8 * 1024)
681 #define Jumbo_Frame_9k (9 * 1024)
682 #define InterFrameGap 0x03 /* 3 means InterFrameGap = the shortest one */
684 #define RX_BUF_SIZE 0x05F3 /* 0x05F3 = 1523 Rx Buffer size */
685 #define R8168_TX_RING_BYTES (NUM_TX_DESC * sizeof(struct TxDesc))
686 #define R8168_RX_RING_BYTES (NUM_RX_DESC * sizeof(struct RxDesc))
688 #define NUM_TX_DESC 1024 /* Number of Tx descriptor registers */
689 #define NUM_RX_DESC 1024 /* Number of Rx descriptor registers */
701 CFG_METHOD_10
= 0x0a,
702 CFG_METHOD_11
= 0x0b,
705 enum RTL8168_DSM_STATE
{
709 DSM_NIC_RESUME_D3
= 4,
713 enum RTL8168_registers
{
714 MAC0
= 0, /* Ethernet hardware address. */
716 MAR0
= 8, /* Multicast filter. */
717 CounterAddrLow
= 0x10,
718 CounterAddrHigh
= 0x14,
719 TxDescStartAddrLow
= 0x20,
720 TxDescStartAddrHigh
= 0x24,
721 TxHDescStartAddrLow
= 0x28,
722 TxHDescStartAddrHigh
= 0x2c,
751 RxDescAddrLow
= 0xE4,
752 RxDescAddrHigh
= 0xE8,
755 FuncEventMask
= 0xF4,
756 FuncPresetState
= 0xF8,
757 FuncForceEvent
= 0xFC,
760 enum RTL8168_register_content
{
761 /* InterruptStatusBits */
765 TxDescUnavail
= 0x0080,
768 RxDescUnavail
= 0x0010,
789 Cfg9346_Unlock
= 0xC0,
794 AcceptBroadcast
= 0x08,
795 AcceptMulticast
= 0x04,
797 AcceptAllPhys
= 0x01,
799 /* Transmit Priority Polling*/
805 Reserved2_shift
= 13,
807 RxCfg_128_int_en
= (1 << 15),
808 RxCfg_fet_multi_en
= (1 << 14),
809 RxCfg_half_refetch
= (1 << 13),
812 TxInterFrameGapShift
= 24,
813 TxDMAShift
= 8, /* DMA burst value (0-7) is shift this many bits */
814 TxMACLoopBack
= (1 << 17), /* MAC loopback */
816 /* Config1 register p.24 */
819 Speed_down
= (1 << 4),
823 PMEnable
= (1 << 0), /* Power Management Enable */
825 /* Config3 register */
826 MagicPacket
= (1 << 5), /* Wake up when receives a Magic Packet */
827 LinkUp
= (1 << 4), /* This bit is reserved in RTL8168B.*/
828 /* Wake up when the cable connection is re-established */
829 ECRCEN
= (1 << 3), /* This bit is reserved in RTL8168B*/
830 Jumbo_En0
= (1 << 2), /* This bit is reserved in RTL8168B*/
831 RDY_TO_L23
= (1 << 1), /* This bit is reserved in RTL8168B*/
832 Beacon_en
= (1 << 0), /* This bit is reserved in RTL8168B*/
834 /* Config4 register */
835 Jumbo_En1
= (1 << 1), /* This bit is reserved in RTL8168B*/
837 /* Config5 register */
838 BWF
= (1 << 6), /* Accept Broadcast wakeup frame */
839 MWF
= (1 << 5), /* Accept Multicast wakeup frame */
840 UWF
= (1 << 4), /* Accept Unicast wakeup frame */
841 LanWake
= (1 << 1), /* LanWake enable/disable */
842 PMEStatus
= (1 << 0), /* PME status can be reset by PCI RST# */
845 EnableBist
= (1 << 15),
846 Macdbgo_oe
= (1 << 14),
847 Normal_mode
= (1 << 13),
848 Force_halfdup
= (1 << 12),
849 Force_rxflow_en
= (1 << 11),
850 Force_txflow_en
= (1 << 10),
851 Cxpl_dbg_sel
= (1 << 9),//This bit is reserved in RTL8168B
852 ASF
= (1 << 8),//This bit is reserved in RTL8168C
853 PktCntrDisable
= (1 << 7),
856 Macdbgo_sel
= 0x001C,
862 /* rtl8168_PHYstatus */
872 Fix_Nak_1
= (1 << 4),
873 Fix_Nak_2
= (1 << 3),
874 DBGPIN_E2
= (1 << 0),
876 /* DumpCounterCommand */
880 PHYAR_Flag
= 0x80000000,
881 PHYAR_Write
= 0x80000000,
882 PHYAR_Read
= 0x00000000,
883 PHYAR_Reg_Mask
= 0x1f,
884 PHYAR_Reg_shift
= 16,
885 PHYAR_Data_Mask
= 0xffff,
888 EPHYAR_Flag
= 0x80000000,
889 EPHYAR_Write
= 0x80000000,
890 EPHYAR_Read
= 0x00000000,
891 EPHYAR_Reg_Mask
= 0x1f,
892 EPHYAR_Reg_shift
= 16,
893 EPHYAR_Data_Mask
= 0xffff,
896 CSIAR_Flag
= 0x80000000,
897 CSIAR_Write
= 0x80000000,
898 CSIAR_Read
= 0x00000000,
900 CSIAR_ByteEn_shift
= 12,
901 CSIAR_Addr_Mask
= 0x0fff,
907 enum _DescStatusBit
{
908 DescOwn
= (1 << 31), /* Descriptor is owned by NIC */
909 RingEnd
= (1 << 30), /* End of descriptor ring */
910 FirstFrag
= (1 << 29), /* First segment of a packet */
911 LastFrag
= (1 << 28), /* Final segment of a packet */
914 /*------ offset 0 of tx descriptor ------*/
915 LargeSend
= (1 << 27), /* TCP Large Send Offload (TSO) */
916 MSSShift
= 16, /* MSS value position */
917 MSSMask
= 0xfff, /* MSS value + LargeSend bit: 12 bits */
918 TxIPCS
= (1 << 18), /* Calculate IP checksum */
919 TxUDPCS
= (1 << 17), /* Calculate UDP/IP checksum */
920 TxTCPCS
= (1 << 16), /* Calculate TCP/IP checksum */
921 TxVlanTag
= (1 << 17), /* Add VLAN tag */
923 /*@@@@@@ offset 4 of tx descriptor => bits for RTL8168C/CP only begin @@@@@@*/
924 TxUDPCS_C
= (1 << 31), /* Calculate UDP/IP checksum */
925 TxTCPCS_C
= (1 << 30), /* Calculate TCP/IP checksum */
926 TxIPCS_C
= (1 << 29), /* Calculate IP checksum */
927 /*@@@@@@ offset 4 of tx descriptor => bits for RTL8168C/CP only end @@@@@@*/
931 /*------ offset 0 of rx descriptor ------*/
932 PID1
= (1 << 18), /* Protocol ID bit 1/2 */
933 PID0
= (1 << 17), /* Protocol ID bit 2/2 */
935 #define RxProtoUDP (PID1)
936 #define RxProtoTCP (PID0)
937 #define RxProtoIP (PID1 | PID0)
938 #define RxProtoMask RxProtoIP
940 RxIPF
= (1 << 16), /* IP checksum failed */
941 RxUDPF
= (1 << 15), /* UDP/IP checksum failed */
942 RxTCPF
= (1 << 14), /* TCP/IP checksum failed */
943 RxVlanTag
= (1 << 16), /* VLAN tag available */
945 /*@@@@@@ offset 0 of rx descriptor => bits for RTL8168C/CP only begin @@@@@@*/
948 /*@@@@@@ offset 0 of rx descriptor => bits for RTL8168C/CP only end @@@@@@*/
950 /*@@@@@@ offset 4 of rx descriptor => bits for RTL8168C/CP only begin @@@@@@*/
953 /*@@@@@@ offset 4 of rx descriptor => bits for RTL8168C/CP only end @@@@@@*/
957 // RTL_FEATURE_WOL = (1 << 0),
958 RTL_FEATURE_MSI
= (1 << 1),
961 #define RsvdMask 0x3fffc000
975 void rtl8168nic_get_functions(struct RTL8168Unit
*Unit
);
976 void rtl8168nic_USecDelay(struct net_device
*, ULONG
);
977 #define udelay(usec) rtl8168nic_USecDelay(unit, usec)