1 /* sis900.c: A SiS 900/7016 PCI Fast Ethernet driver for Linux.
2 Copyright 1999 Silicon Integrated System Corporation
3 Revision: 1.06.03 Dec 23 1999
5 Modified from the driver which is originally written by Donald Becker.
7 This software may be used and distributed according to the terms
8 of the GNU Public License (GPL), incorporated herein by reference.
9 Drivers based on this skeleton fall under the GPL and must retain
10 the authorship (implicit copyright) notice.
13 SiS 7016 Fast Ethernet PCI Bus 10/100 Mbps LAN Controller with OnNow Support,
14 preliminary Rev. 1.0 Jan. 14, 1998
15 SiS 900 Fast Ethernet PCI Bus 10/100 Mbps LAN Single Chip with OnNow Support,
16 preliminary Rev. 1.0 Nov. 10, 1998
17 SiS 7014 Single Chip 100BASE-TX/10BASE-T Physical Layer Solution,
18 preliminary Rev. 1.0 Jan. 18, 1998
19 http://www.sis.com.tw/support/databook.htm
21 Rev 1.06.04 Feb. 11 2000 Jeff Garzik <jgarzik@mandrakesoft.com> softnet and init for kernel 2.4
22 Rev 1.06.03 Dec. 23 1999 Ollie Lho Third release
23 Rev 1.06.02 Nov. 23 1999 Ollie Lho bug in mac probing fixed
24 Rev 1.06.01 Nov. 16 1999 Ollie Lho CRC calculation provide by Joseph Zbiciak (im14u2c@primenet.com)
25 Rev 1.06 Nov. 4 1999 Ollie Lho (ollie@sis.com.tw) Second release
26 Rev 1.05.05 Oct. 29 1999 Ollie Lho (ollie@sis.com.tw) Single buffer Tx/Rx
27 Chin-Shan Li (lcs@sis.com.tw) Added AMD Am79c901 HomePNA PHY support
28 Rev 1.05 Aug. 7 1999 Jim Huang (cmhuang@sis.com.tw) Initial release
31 #include <linux/module.h>
32 #include <linux/version.h>
33 #include <linux/kernel.h>
34 #include <linux/sched.h>
35 #include <linux/string.h>
36 #include <linux/timer.h>
37 #include <linux/errno.h>
38 #include <linux/ioport.h>
39 #include <linux/malloc.h>
40 #include <linux/interrupt.h>
41 #include <linux/pci.h>
42 #include <linux/netdevice.h>
43 #include <linux/init.h>
45 #include <linux/etherdevice.h>
46 #include <linux/skbuff.h>
47 #include <asm/processor.h> /* Processor type for cache alignment. */
48 #include <asm/bitops.h>
50 #include <linux/delay.h>
54 static const char *version
=
55 "sis900.c: v1.06.04 02/11/2000\n";
57 static int max_interrupt_work
= 20;
58 #define sis900_debug debug
59 static int sis900_debug
= 0;
61 static int multicast_filter_limit
= 128;
63 /* Time in jiffies before concluding the transmitter is hung. */
64 #define TX_TIMEOUT (4*HZ)
66 struct mac_chip_info
{
68 u16 vendor_id
, device_id
, flags
;
70 struct net_device
*(*probe
) (struct mac_chip_info
*mac
, struct pci_dev
* pci_dev
,
71 struct net_device
* net_dev
);
73 static struct net_device
* sis900_mac_probe (struct mac_chip_info
* mac
, struct pci_dev
* pci_dev
,
74 struct net_device
* net_dev
);
76 static struct mac_chip_info mac_chip_table
[] = {
77 { "SiS 900 PCI Fast Ethernet", PCI_VENDOR_ID_SI
, PCI_DEVICE_ID_SI_900
,
78 PCI_COMMAND_IO
|PCI_COMMAND_MASTER
, SIS900_TOTAL_SIZE
, sis900_mac_probe
},
79 { "SiS 7016 PCI Fast Ethernet",PCI_VENDOR_ID_SI
, PCI_DEVICE_ID_SI_7016
,
80 PCI_COMMAND_IO
|PCI_COMMAND_MASTER
, SIS900_TOTAL_SIZE
, sis900_mac_probe
},
81 {0,}, /* 0 terminated list. */
84 static void sis900_read_mode(struct net_device
*net_dev
, int phy_addr
, int *speed
, int *duplex
);
85 static void amd79c901_read_mode(struct net_device
*net_dev
, int phy_addr
, int *speed
, int *duplex
);
87 static struct mii_chip_info
{
91 void (*read_mode
) (struct net_device
*net_dev
, int phy_addr
, int *speed
, int *duplex
);
92 } mii_chip_table
[] = {
93 {"SiS 900 Internal MII PHY", 0x001d, 0x8000, sis900_read_mode
},
94 {"SiS 7014 Physical Layer Solution", 0x0016, 0xf830,sis900_read_mode
},
95 {"AMD 79C901 10BASE-T PHY", 0x0000, 0x35b9, amd79c901_read_mode
},
96 {"AMD 79C901 HomePNA PHY", 0x0000, 0x35c8, amd79c901_read_mode
},
101 struct mii_phy
* next
;
102 struct mii_chip_info
* chip_info
;
107 typedef struct _BufferDesc
{
113 struct sis900_private
{
114 struct net_device
*next_module
;
115 struct net_device_stats stats
;
116 struct pci_dev
* pci_dev
;
120 struct mac_chip_info
* mac
;
121 struct mii_phy
* mii
;
122 unsigned int cur_phy
;
124 struct timer_list timer
; /* Link status detection timer. */
125 unsigned int cur_rx
, dirty_rx
;
126 unsigned int cur_tx
, dirty_tx
;
128 /* The saved address of a sent/receive-in-place packet buffer */
129 struct sk_buff
*tx_skbuff
[NUM_TX_DESC
];
130 struct sk_buff
*rx_skbuff
[NUM_RX_DESC
];
131 BufferDesc tx_ring
[NUM_TX_DESC
];
132 BufferDesc rx_ring
[NUM_RX_DESC
];
133 unsigned int tx_full
; /* The Tx queue is full. */
138 MODULE_AUTHOR("Jim Huang <cmhuang@sis.com.tw>");
139 MODULE_DESCRIPTION("SiS 900 PCI Fast Ethernet driver");
140 MODULE_PARM(multicast_filter_limit
, "i");
141 MODULE_PARM(max_interrupt_work
, "i");
142 MODULE_PARM(debug
, "i");
144 static int sis900_open(struct net_device
*net_dev
);
145 static int sis900_mii_probe (struct net_device
* net_dev
);
146 static void sis900_init_rxfilter (struct net_device
* net_dev
);
147 static u16
read_eeprom(long ioaddr
, int location
);
148 static u16
mdio_read(struct net_device
*net_dev
, int phy_id
, int location
);
149 static void mdio_write(struct net_device
*net_dev
, int phy_id
, int location
, int val
);
150 static void sis900_timer(unsigned long data
);
151 static void sis900_check_mode (struct net_device
*net_dev
, struct mii_phy
*mii_phy
);
152 static void sis900_tx_timeout(struct net_device
*net_dev
);
153 static void sis900_init_tx_ring(struct net_device
*net_dev
);
154 static void sis900_init_rx_ring(struct net_device
*net_dev
);
155 static int sis900_start_xmit(struct sk_buff
*skb
, struct net_device
*net_dev
);
156 static int sis900_rx(struct net_device
*net_dev
);
157 static void sis900_finish_xmit (struct net_device
*net_dev
);
158 static void sis900_interrupt(int irq
, void *dev_instance
, struct pt_regs
*regs
);
159 static int sis900_close(struct net_device
*net_dev
);
160 static int mii_ioctl(struct net_device
*net_dev
, struct ifreq
*rq
, int cmd
);
161 static struct enet_statistics
*sis900_get_stats(struct net_device
*net_dev
);
162 static u16
sis900_compute_hashtable_index(u8
*addr
);
163 static void set_rx_mode(struct net_device
*net_dev
);
164 static void sis900_reset(struct net_device
*net_dev
);
166 /* A list of all installed SiS900 devices, for removing the driver module. */
167 static struct net_device
*root_sis900_dev
= NULL
;
169 /* walk through every ethernet PCI devices to see if some of them are matched with our card list*/
170 static int __init
sis900_probe (void)
173 struct pci_dev
* pci_dev
= NULL
;
175 while ((pci_dev
= pci_find_class (PCI_CLASS_NETWORK_ETHERNET
<< 8, pci_dev
)) != NULL
) {
176 /* pci_dev contains all ethernet devices */
178 struct mac_chip_info
* mac
;
179 struct net_device
*net_dev
= NULL
;
181 for (mac
= mac_chip_table
; mac
->vendor_id
; mac
++) {
182 /* try to match our card list */
183 if (pci_dev
->vendor
== mac
->vendor_id
&&
184 pci_dev
->device
== mac
->device_id
)
188 if (mac
->vendor_id
== 0)
189 /* pci_dev does not match any of our cards */
192 /* now, pci_dev should be either 900 or 7016 */
193 pci_io_base
= pci_dev
->resource
[0].start
;
194 if ((mac
->flags
& PCI_COMMAND_IO
) &&
195 check_region(pci_io_base
, mac
->io_size
))
198 /* setup various bits in PCI command register */
199 pci_enable_device (pci_dev
);
200 pci_set_master(pci_dev
);
202 /* do the real low level jobs */
203 net_dev
= mac
->probe(mac
, pci_dev
, net_dev
);
205 if (net_dev
!= NULL
) {
210 return found
? 0 : -ENODEV
;
213 static struct net_device
* sis900_mac_probe (struct mac_chip_info
* mac
, struct pci_dev
* pci_dev
,
214 struct net_device
* net_dev
)
216 struct sis900_private
*sis_priv
;
217 long ioaddr
= pci_dev
->resource
[0].start
;
218 int irq
= pci_dev
->irq
;
219 static int did_version
= 0;
223 if (did_version
++ == 0)
224 printk(KERN_INFO
"%s", version
);
226 if ((net_dev
= init_etherdev(net_dev
, 0)) == NULL
)
228 /* check to see if we have sane EEPROM */
229 signature
= (u16
) read_eeprom(ioaddr
, EEPROMSignature
);
230 if (signature
== 0xffff || signature
== 0x0000) {
231 printk (KERN_INFO
"%s: Error EERPOM read %x\n",
232 net_dev
->name
, signature
);
236 printk(KERN_INFO
"%s: %s at %#lx, IRQ %d, ", net_dev
->name
, mac
->name
,
239 /* get MAC address from EEPROM */
240 for (i
= 0; i
< 3; i
++)
241 ((u16
*)(net_dev
->dev_addr
))[i
] = read_eeprom(ioaddr
, i
+EEPROMMACAddr
);
242 for (i
= 0; i
< 5; i
++)
243 printk("%2.2x:", (u8
)net_dev
->dev_addr
[i
]);
244 printk("%2.2x.\n", net_dev
->dev_addr
[i
]);
246 if ((net_dev
->priv
= kmalloc(sizeof(struct sis900_private
), GFP_KERNEL
)) == NULL
) {
247 unregister_netdevice(net_dev
);
251 sis_priv
= net_dev
->priv
;
252 memset(sis_priv
, 0, sizeof(struct sis900_private
));
254 /* We do a request_region() to register /proc/ioports info. */
255 request_region(ioaddr
, mac
->io_size
, net_dev
->name
);
256 net_dev
->base_addr
= ioaddr
;
258 sis_priv
->pci_dev
= pci_dev
;
260 sis_priv
->lock
= SPIN_LOCK_UNLOCKED
;
262 /* probe for mii transciver */
263 if (sis900_mii_probe(net_dev
) == 0) {
264 unregister_netdev(net_dev
);
266 release_region(ioaddr
, mac
->io_size
);
270 sis_priv
->next_module
= root_sis900_dev
;
271 root_sis900_dev
= net_dev
;
273 /* The SiS900-specific entries in the device structure. */
274 net_dev
->open
= &sis900_open
;
275 net_dev
->hard_start_xmit
= &sis900_start_xmit
;
276 net_dev
->stop
= &sis900_close
;
277 net_dev
->get_stats
= &sis900_get_stats
;
278 net_dev
->set_multicast_list
= &set_rx_mode
;
279 net_dev
->do_ioctl
= &mii_ioctl
;
280 net_dev
->tx_timeout
= sis900_tx_timeout
;
281 net_dev
->watchdog_timeo
= TX_TIMEOUT
;
286 static int sis900_mii_probe (struct net_device
* net_dev
)
288 struct sis900_private
* sis_priv
= (struct sis900_private
*)net_dev
->priv
;
291 sis_priv
->mii
= NULL
;
293 /* search for total of 32 possible mii phy addresses */
294 for (phy_addr
= 0; phy_addr
< 32; phy_addr
++) {
296 u16 phy_id0
, phy_id1
;
299 mii_status
= mdio_read(net_dev
, phy_addr
, MII_STATUS
);
300 if (mii_status
== 0xffff || mii_status
== 0x0000)
301 /* the mii is not accessable, try next one */
304 phy_id0
= mdio_read(net_dev
, phy_addr
, MII_PHY_ID0
);
305 phy_id1
= mdio_read(net_dev
, phy_addr
, MII_PHY_ID1
);
307 /* search our mii table for the current mii */
308 for (i
= 0; mii_chip_table
[i
].phy_id1
; i
++)
309 if (phy_id0
== mii_chip_table
[i
].phy_id0
) {
310 struct mii_phy
* mii_phy
;
313 "%s: %s transceiver found at address %d.\n",
314 net_dev
->name
, mii_chip_table
[i
].name
,
316 if ((mii_phy
= kmalloc(sizeof(struct mii_phy
), GFP_KERNEL
)) != NULL
) {
317 mii_phy
->chip_info
= mii_chip_table
+i
;
318 mii_phy
->phy_addr
= phy_addr
;
319 mii_phy
->status
= mdio_read(net_dev
, phy_addr
,
321 mii_phy
->next
= sis_priv
->mii
;
322 sis_priv
->mii
= mii_phy
;
324 /* the current mii is on our mii_info_table,
330 if (sis_priv
->mii
== NULL
) {
331 printk(KERN_INFO
"%s: No MII transceivers found!\n",
336 /* arbitrary choose that last PHY and current PHY */
337 sis_priv
->cur_phy
= sis_priv
->mii
->phy_addr
;
338 printk(KERN_INFO
"%s: Using %s as default\n", net_dev
->name
,
339 sis_priv
->mii
->chip_info
->name
);
341 if (sis_priv
->mii
->status
& MII_STAT_LINK
)
342 sis_priv
->LinkOn
= TRUE
;
344 sis_priv
->LinkOn
= FALSE
;
349 /* Delay between EEPROM clock transitions. */
350 #define eeprom_delay() inl(ee_addr)
352 /* Read Serial EEPROM through EEPROM Access Register, Note that location is
353 in word (16 bits) unit */
354 static u16
read_eeprom(long ioaddr
, int location
)
358 long ee_addr
= ioaddr
+ mear
;
359 u32 read_cmd
= location
| EEread
;
363 outl(EECLK
, ee_addr
);
366 /* Shift the read command (9) bits out. */
367 for (i
= 8; i
>= 0; i
--) {
368 u32 dataval
= (read_cmd
& (1 << i
)) ? EEDI
| EECS
: EECS
;
369 outl(dataval
, ee_addr
);
371 outl(dataval
| EECLK
, ee_addr
);
377 /* read the 16-bits data in */
378 for (i
= 16; i
> 0; i
--) {
381 outl(EECS
| EECLK
, ee_addr
);
383 retval
= (retval
<< 1) | ((inl(ee_addr
) & EEDO
) ? 1 : 0);
387 /* Terminate the EEPROM access. */
390 outl(EECLK
, ee_addr
);
395 /* Read and write the MII management registers using software-generated
396 serial MDIO protocol. Note that the command bits and data bits are
397 send out seperately */
398 #define mdio_delay() inl(mdio_addr)
400 static void mdio_idle(long mdio_addr
)
402 outl(MDIO
| MDDIR
, mdio_addr
);
404 outl(MDIO
| MDDIR
| MDC
, mdio_addr
);
407 /* Syncronize the MII management interface by shifting 32 one bits out. */
408 static void mdio_reset(long mdio_addr
)
412 for (i
= 31; i
>= 0; i
--) {
413 outl(MDDIR
| MDIO
, mdio_addr
);
415 outl(MDDIR
| MDIO
| MDC
, mdio_addr
);
421 static u16
mdio_read(struct net_device
*net_dev
, int phy_id
, int location
)
423 long mdio_addr
= net_dev
->base_addr
+ mear
;
424 int mii_cmd
= MIIread
|(phy_id
<<MIIpmdShift
)|(location
<<MIIregShift
);
428 mdio_reset(mdio_addr
);
429 mdio_idle(mdio_addr
);
431 for (i
= 15; i
>= 0; i
--) {
432 int dataval
= (mii_cmd
& (1 << i
)) ? MDDIR
| MDIO
: MDDIR
;
433 outl(dataval
, mdio_addr
);
435 outl(dataval
| MDC
, mdio_addr
);
439 /* Read the 16 data bits. */
440 for (i
= 16; i
> 0; i
--) {
443 retval
= (retval
<< 1) | ((inl(mdio_addr
) & MDIO
) ? 1 : 0);
444 outl(MDC
, mdio_addr
);
450 static void mdio_write(struct net_device
*net_dev
, int phy_id
, int location
, int value
)
452 long mdio_addr
= net_dev
->base_addr
+ mear
;
453 int mii_cmd
= MIIwrite
|(phy_id
<<MIIpmdShift
)|(location
<<MIIregShift
);
456 mdio_reset(mdio_addr
);
457 mdio_idle(mdio_addr
);
459 /* Shift the command bits out. */
460 for (i
= 15; i
>= 0; i
--) {
461 int dataval
= (mii_cmd
& (1 << i
)) ? MDDIR
| MDIO
: MDDIR
;
462 outb(dataval
, mdio_addr
);
464 outb(dataval
| MDC
, mdio_addr
);
469 /* Shift the value bits out. */
470 for (i
= 15; i
>= 0; i
--) {
471 int dataval
= (value
& (1 << i
)) ? MDDIR
| MDIO
: MDDIR
;
472 outl(dataval
, mdio_addr
);
474 outl(dataval
| MDC
, mdio_addr
);
479 /* Clear out extra bits. */
480 for (i
= 2; i
> 0; i
--) {
483 outb(MDC
, mdio_addr
);
490 sis900_open(struct net_device
*net_dev
)
492 struct sis900_private
*sis_priv
= (struct sis900_private
*)net_dev
->priv
;
493 long ioaddr
= net_dev
->base_addr
;
495 /* Soft reset the chip. */
496 sis900_reset(net_dev
);
498 if (request_irq(net_dev
->irq
, &sis900_interrupt
, SA_SHIRQ
, net_dev
->name
, net_dev
)) {
504 sis900_init_rxfilter(net_dev
);
506 sis900_init_tx_ring(net_dev
);
507 sis900_init_rx_ring(net_dev
);
509 set_rx_mode(net_dev
);
511 netif_start_queue(net_dev
);
513 /* Enable all known interrupts by setting the interrupt mask. */
514 outl((RxSOVR
|RxORN
|RxERR
|RxOK
|TxURN
|TxERR
|TxIDLE
), ioaddr
+ imr
);
515 outl(RxENA
, ioaddr
+ cr
);
516 outl(IE
, ioaddr
+ ier
);
518 sis900_check_mode(net_dev
, sis_priv
->mii
);
520 /* Set the timer to switch to check for link beat and perhaps switch
521 to an alternate media type. */
522 init_timer(&sis_priv
->timer
);
523 sis_priv
->timer
.expires
= jiffies
+ HZ
;
524 sis_priv
->timer
.data
= (unsigned long)net_dev
;
525 sis_priv
->timer
.function
= &sis900_timer
;
526 add_timer(&sis_priv
->timer
);
531 /* set receive filter address to our MAC address */
533 sis900_init_rxfilter (struct net_device
* net_dev
)
535 long ioaddr
= net_dev
->base_addr
;
539 rfcrSave
= inl(rfcr
+ ioaddr
);
541 /* disable packet filtering before setting filter */
542 outl(rfcrSave
& ~RFEN
, rfcr
);
544 /* load MAC addr to filter data register */
545 for (i
= 0 ; i
< 3 ; i
++) {
548 w
= (u32
) *((u16
*)(net_dev
->dev_addr
)+i
);
549 outl((i
<< RFADDR_shift
), ioaddr
+ rfcr
);
550 outl(w
, ioaddr
+ rfdr
);
552 if (sis900_debug
> 2) {
553 printk(KERN_INFO
"%s: Receive Filter Addrss[%d]=%x\n",
554 net_dev
->name
, i
, inl(ioaddr
+ rfdr
));
558 /* enable packet filitering */
559 outl(rfcrSave
| RFEN
, rfcr
+ ioaddr
);
562 /* Initialize the Tx ring. */
564 sis900_init_tx_ring(struct net_device
*net_dev
)
566 struct sis900_private
*sis_priv
= (struct sis900_private
*)net_dev
->priv
;
567 long ioaddr
= net_dev
->base_addr
;
570 sis_priv
->tx_full
= 0;
571 sis_priv
->dirty_tx
= sis_priv
->cur_tx
= 0;
573 for (i
= 0; i
< NUM_TX_DESC
; i
++) {
574 sis_priv
->tx_skbuff
[i
] = NULL
;
576 sis_priv
->tx_ring
[i
].link
= (u32
) virt_to_bus(&sis_priv
->tx_ring
[i
+1]);
577 sis_priv
->tx_ring
[i
].cmdsts
= 0;
578 sis_priv
->tx_ring
[i
].bufptr
= 0;
580 sis_priv
->tx_ring
[i
-1].link
= (u32
) virt_to_bus(&sis_priv
->tx_ring
[0]);
582 /* load Transmit Descriptor Register */
583 outl(virt_to_bus(&sis_priv
->tx_ring
[0]), ioaddr
+ txdp
);
584 if (sis900_debug
> 2)
585 printk(KERN_INFO
"%s: TX descriptor register loaded with: %8.8x\n",
586 net_dev
->name
, inl(ioaddr
+ txdp
));
589 /* Initialize the Rx descriptor ring, pre-allocate recevie buffers */
591 sis900_init_rx_ring(struct net_device
*net_dev
)
593 struct sis900_private
*sis_priv
= (struct sis900_private
*)net_dev
->priv
;
594 long ioaddr
= net_dev
->base_addr
;
597 sis_priv
->cur_rx
= 0;
598 sis_priv
->dirty_rx
= 0;
600 /* init RX descriptor */
601 for (i
= 0; i
< NUM_RX_DESC
; i
++) {
602 sis_priv
->rx_skbuff
[i
] = NULL
;
604 sis_priv
->rx_ring
[i
].link
= (u32
) virt_to_bus(&sis_priv
->rx_ring
[i
+1]);
605 sis_priv
->rx_ring
[i
].cmdsts
= 0;
606 sis_priv
->rx_ring
[i
].bufptr
= 0;
608 sis_priv
->rx_ring
[i
-1].link
= (u32
) virt_to_bus(&sis_priv
->rx_ring
[0]);
610 /* allocate sock buffers */
611 for (i
= 0; i
< NUM_RX_DESC
; i
++) {
614 if ((skb
= dev_alloc_skb(RX_BUF_SIZE
)) == NULL
) {
615 /* not enough memory for skbuff, this makes a "hole"
616 on the buffer ring, it is not clear how the
617 hardware will react to this kind of degenerated
622 sis_priv
->rx_skbuff
[i
] = skb
;
623 sis_priv
->rx_ring
[i
].cmdsts
= RX_BUF_SIZE
;
624 sis_priv
->rx_ring
[i
].bufptr
= virt_to_bus(skb
->tail
);
626 sis_priv
->dirty_rx
= (unsigned int) (i
- NUM_RX_DESC
);
628 /* load Receive Descriptor Register */
629 outl(virt_to_bus(&sis_priv
->rx_ring
[0]), ioaddr
+ rxdp
);
630 if (sis900_debug
> 2)
631 printk(KERN_INFO
"%s: RX descriptor register loaded with: %8.8x\n",
632 net_dev
->name
, inl(ioaddr
+ rxdp
));
634 /* on each timer ticks we check two things, Link Status (ON/OFF) and
635 Link Mode (10/100/Full/Half)
637 static void sis900_timer(unsigned long data
)
639 struct net_device
*net_dev
= (struct net_device
*)data
;
640 struct sis900_private
*sis_priv
= (struct sis900_private
*)net_dev
->priv
;
641 struct mii_phy
*mii_phy
= sis_priv
->mii
;
642 static int next_tick
= 5*HZ
;
645 status
= mdio_read(net_dev
, sis_priv
->cur_phy
, MII_STATUS
);
647 /* current mii phy is failed to link, try another one */
648 while (!(status
& MII_STAT_LINK
)) {
649 if (mii_phy
->next
== NULL
) {
650 if (sis_priv
->LinkOn
) {
651 /* link stat change from ON to OFF */
653 sis_priv
->LinkOn
= FALSE
;
654 printk(KERN_INFO
"%s: Media Link Off\n",
657 sis_priv
->timer
.expires
= jiffies
+ next_tick
;
658 add_timer(&sis_priv
->timer
);
661 mii_phy
= mii_phy
->next
;
662 status
= mdio_read(net_dev
, mii_phy
->phy_addr
, MII_STATUS
);
665 if (!sis_priv
->LinkOn
) {
666 /* link stat change forn OFF to ON, read and report link mode */
667 sis_priv
->LinkOn
= TRUE
;
669 /* change what cur_phy means */
670 if (mii_phy
->phy_addr
!= sis_priv
->cur_phy
) {
671 printk(KERN_INFO
"%s: Changing transceiver to %s\n", net_dev
->name
,
672 mii_phy
->chip_info
->name
);
673 status
= mdio_read(net_dev
, sis_priv
->cur_phy
, MII_CONTROL
);
674 mdio_write(net_dev
, sis_priv
->cur_phy
,
675 MII_CONTROL
, status
| MII_CNTL_ISOLATE
);
676 status
= mdio_read(net_dev
, mii_phy
->phy_addr
, MII_CONTROL
);
677 mdio_write(net_dev
, mii_phy
->phy_addr
,
678 MII_CONTROL
, status
& ~MII_CNTL_ISOLATE
);
679 sis_priv
->cur_phy
= mii_phy
->phy_addr
;
681 sis900_check_mode(net_dev
, mii_phy
);
684 sis_priv
->timer
.expires
= jiffies
+ next_tick
;
685 add_timer(&sis_priv
->timer
);
687 static void sis900_check_mode (struct net_device
*net_dev
, struct mii_phy
*mii_phy
)
689 struct sis900_private
*sis_priv
= (struct sis900_private
*)net_dev
->priv
;
690 long ioaddr
= net_dev
->base_addr
;
692 u32 tx_flags
= 0, rx_flags
= 0;
694 mii_phy
->chip_info
->read_mode(net_dev
, sis_priv
->cur_phy
, &speed
, &duplex
);
696 tx_flags
= TxATP
| (TX_DMA_BURST
<< TxMXDMA_shift
) | (TX_FILL_THRESH
<< TxFILLT_shift
);
697 rx_flags
= RX_DMA_BURST
<< RxMXDMA_shift
;
699 if (speed
== HW_SPEED_HOME
|| speed
== HW_SPEED_10_MBPS
) {
700 rx_flags
|= (RxDRNT_10
<< RxDRNT_shift
);
701 tx_flags
|= (TxDRNT_10
<< TxDRNT_shift
);
704 rx_flags
|= (RxDRNT_100
<< RxDRNT_shift
);
705 tx_flags
|= (TxDRNT_100
<< TxDRNT_shift
);
708 if (duplex
== FDX_CAPABLE_FULL_SELECTED
) {
709 tx_flags
|= (TxCSI
| TxHBI
);
713 outl (tx_flags
, ioaddr
+ txcfg
);
714 outl (rx_flags
, ioaddr
+ rxcfg
);
716 static void sis900_read_mode(struct net_device
*net_dev
, int phy_addr
, int *speed
, int *duplex
)
721 /* STSOUT register is Latched on Transition, read operation updates it */
723 status
= mdio_read(net_dev
, phy_addr
, MII_STSOUT
);
725 if (status
& MII_STSOUT_SPD
)
726 *speed
= HW_SPEED_100_MBPS
;
728 *speed
= HW_SPEED_10_MBPS
;
730 if (status
& MII_STSOUT_DPLX
)
731 *duplex
= FDX_CAPABLE_FULL_SELECTED
;
733 *duplex
= FDX_CAPABLE_HALF_SELECTED
;
735 if (status
& MII_STSOUT_LINK_FAIL
)
736 printk(KERN_INFO
"%s: Media Link Off\n", net_dev
->name
);
738 printk(KERN_INFO
"%s: Media Link On %s %s-duplex \n",
740 *speed
== HW_SPEED_100_MBPS
?
741 "100mbps" : "10mbps",
742 *duplex
== FDX_CAPABLE_FULL_SELECTED
?
745 static void amd79c901_read_mode(struct net_device
*net_dev
, int phy_addr
, int *speed
, int *duplex
)
750 for (i
= 0; i
< 2; i
++)
751 status
= mdio_read(net_dev
, phy_addr
, MII_STATUS
);
753 if (status
& MII_STAT_CAN_AUTO
) {
755 for (i
= 0; i
< 2; i
++)
756 status
= mdio_read(net_dev
, phy_addr
, MII_STATUS_SUMMARY
);
757 if (status
& MII_STSSUM_SPD
)
758 *speed
= HW_SPEED_100_MBPS
;
760 *speed
= HW_SPEED_10_MBPS
;
761 if (status
& MII_STSSUM_DPLX
)
762 *duplex
= FDX_CAPABLE_FULL_SELECTED
;
764 *duplex
= FDX_CAPABLE_HALF_SELECTED
;
766 if (status
& MII_STSSUM_LINK
)
767 printk(KERN_INFO
"%s: Media Link On %s %s-duplex \n",
769 *speed
== HW_SPEED_100_MBPS
?
770 "100mbps" : "10mbps",
771 *duplex
== FDX_CAPABLE_FULL_SELECTED
?
774 printk(KERN_INFO
"%s: Media Link Off\n", net_dev
->name
);
779 *speed
= HW_SPEED_HOME
;
780 *duplex
= FDX_CAPABLE_HALF_SELECTED
;
781 if (status
& MII_STAT_LINK
)
782 printk(KERN_INFO
"%s: Media Link On 1mbps half-duplex \n",
785 printk(KERN_INFO
"%s: Media Link Off\n", net_dev
->name
);
788 static void sis900_tx_timeout(struct net_device
*net_dev
)
790 struct sis900_private
*sis_priv
= (struct sis900_private
*)net_dev
->priv
;
791 long ioaddr
= net_dev
->base_addr
;
795 printk(KERN_INFO
"%s: Transmit timeout, status %8.8x %8.8x \n",
796 net_dev
->name
, inl(ioaddr
+ cr
), inl(ioaddr
+ isr
));
798 /* Disable interrupts by clearing the interrupt mask. */
799 outl(0x0000, ioaddr
+ imr
);
801 /* discard unsent packets, should this code section be protected by
803 spin_lock_irqsave(&sis_priv
->lock
, flags
);
804 sis_priv
->dirty_tx
= sis_priv
->cur_tx
= 0;
805 for (i
= 0; i
< NUM_TX_DESC
; i
++) {
806 if (sis_priv
->tx_skbuff
[i
] != NULL
) {
807 dev_kfree_skb(sis_priv
->tx_skbuff
[i
]);
808 sis_priv
->tx_skbuff
[i
] = 0;
809 sis_priv
->tx_ring
[i
].cmdsts
= 0;
810 sis_priv
->tx_ring
[i
].bufptr
= 0;
811 sis_priv
->stats
.tx_dropped
++;
814 spin_unlock_irqrestore(&sis_priv
->lock
, flags
);
816 net_dev
->trans_start
= jiffies
;
817 sis_priv
->tx_full
= 0;
818 netif_start_queue(net_dev
);
820 /* FIXME: Should we restart the transmission thread here ?? */
822 /* Enable all known interrupts by setting the interrupt mask. */
823 outl((RxSOVR
|RxORN
|RxERR
|RxOK
|TxURN
|TxERR
|TxIDLE
), ioaddr
+ imr
);
828 sis900_start_xmit(struct sk_buff
*skb
, struct net_device
*net_dev
)
830 struct sis900_private
*sis_priv
= (struct sis900_private
*)net_dev
->priv
;
831 long ioaddr
= net_dev
->base_addr
;
834 /* Calculate the next Tx descriptor entry. */
835 entry
= sis_priv
->cur_tx
% NUM_TX_DESC
;
836 sis_priv
->tx_skbuff
[entry
] = skb
;
838 /* set the transmit buffer descriptor and enable Transmit State Machine */
839 sis_priv
->tx_ring
[entry
].bufptr
= virt_to_bus(skb
->data
);
840 sis_priv
->tx_ring
[entry
].cmdsts
= (OWN
| skb
->len
);
841 outl(TxENA
, ioaddr
+ cr
);
843 if (++sis_priv
->cur_tx
- sis_priv
->dirty_tx
< NUM_TX_DESC
) {
844 /* Typical path, clear tbusy to indicate more
845 transmission is possible */
846 netif_start_queue(net_dev
);
848 /* no more transmit descriptor avaiable, tbusy remain set */
849 sis_priv
->tx_full
= 1;
852 net_dev
->trans_start
= jiffies
;
854 if (sis900_debug
> 3)
855 printk(KERN_INFO
"%s: Queued Tx packet at %p size %d "
857 net_dev
->name
, skb
->data
, (int)skb
->len
, entry
);
862 /* The interrupt handler does all of the Rx thread work and cleans up
863 after the Tx thread. */
864 static void sis900_interrupt(int irq
, void *dev_instance
, struct pt_regs
*regs
)
866 struct net_device
*net_dev
= (struct net_device
*)dev_instance
;
867 struct sis900_private
*sis_priv
= (struct sis900_private
*)net_dev
->priv
;
868 int boguscnt
= max_interrupt_work
;
869 long ioaddr
= net_dev
->base_addr
;
872 spin_lock (&sis_priv
->lock
);
875 status
= inl(ioaddr
+ isr
);
877 if ((status
& (HIBERR
|TxURN
|TxERR
|TxIDLE
|RxORN
|RxERR
|RxOK
)) == 0)
878 /* nothing intresting happened */
881 /* why dow't we break after Tx/Rx case ?? keyword: full-duplex */
882 if (status
& (RxORN
| RxERR
| RxOK
))
886 if (status
& (TxURN
| TxERR
| TxIDLE
))
888 sis900_finish_xmit(net_dev
);
890 /* something strange happened !!! */
891 if (status
& HIBERR
) {
892 printk(KERN_INFO
"%s: Abnormal interrupt,"
893 "status %#8.8x.\n", net_dev
->name
, status
);
896 if (--boguscnt
< 0) {
897 printk(KERN_INFO
"%s: Too much work at interrupt, "
898 "interrupt status = %#8.8x.\n",
899 net_dev
->name
, status
);
904 if (sis900_debug
> 3)
905 printk(KERN_INFO
"%s: exiting interrupt, "
906 "interrupt status = 0x%#8.8x.\n",
907 net_dev
->name
, inl(ioaddr
+ isr
));
909 spin_unlock (&sis_priv
->lock
);
913 /* Process receive interrupt events, put buffer to higher layer and refill buffer pool
914 Note: This fucntion is called by interrupt handler, don't do "too much" work here */
915 static int sis900_rx(struct net_device
*net_dev
)
917 struct sis900_private
*sis_priv
= (struct sis900_private
*)net_dev
->priv
;
918 long ioaddr
= net_dev
->base_addr
;
919 unsigned int entry
= sis_priv
->cur_rx
% NUM_RX_DESC
;
920 u32 rx_status
= sis_priv
->rx_ring
[entry
].cmdsts
;
922 if (sis900_debug
> 3)
923 printk(KERN_INFO
"sis900_rx, cur_rx:%4.4d, dirty_rx:%4.4d "
925 sis_priv
->cur_rx
, sis_priv
->dirty_rx
,rx_status
);
927 while (rx_status
& OWN
) {
928 unsigned int rx_size
;
930 rx_size
= (rx_status
& DSIZE
) - CRC_SIZE
;
932 if (rx_status
& (ABORT
|OVERRUN
|TOOLONG
|RUNT
|RXISERR
|CRCERR
|FAERR
)) {
933 /* corrupted packet received */
934 if (sis900_debug
> 3)
935 printk(KERN_INFO
"%s: Corrupted packet "
936 "received, buffer status = 0x%8.8x.\n",
937 net_dev
->name
, rx_status
);
938 sis_priv
->stats
.rx_errors
++;
939 if (rx_status
& OVERRUN
)
940 sis_priv
->stats
.rx_over_errors
++;
941 if (rx_status
& (TOOLONG
|RUNT
))
942 sis_priv
->stats
.rx_length_errors
++;
943 if (rx_status
& (RXISERR
| FAERR
))
944 sis_priv
->stats
.rx_frame_errors
++;
945 if (rx_status
& CRCERR
)
946 sis_priv
->stats
.rx_crc_errors
++;
947 /* reset buffer descriptor state */
948 sis_priv
->rx_ring
[entry
].cmdsts
= RX_BUF_SIZE
;
950 struct sk_buff
* skb
;
952 /* This situation should never happen, but due to
953 some unknow bugs, it is possible that
954 we are working on NULL sk_buff :-( */
955 if (sis_priv
->rx_skbuff
[entry
] == NULL
) {
956 printk(KERN_INFO
"%s: NULL pointer "
957 "encountered in Rx ring, skipping\n",
961 skb
= sis_priv
->rx_skbuff
[entry
];
962 sis_priv
->rx_skbuff
[entry
] = NULL
;
963 /* reset buffer descriptor state */
964 sis_priv
->rx_ring
[entry
].cmdsts
= 0;
965 sis_priv
->rx_ring
[entry
].bufptr
= 0;
967 skb_put(skb
, rx_size
);
968 skb
->protocol
= eth_type_trans(skb
, net_dev
);
971 if ((rx_status
& BCAST
) == MCAST
)
972 sis_priv
->stats
.multicast
++;
973 net_dev
->last_rx
= jiffies
;
974 sis_priv
->stats
.rx_bytes
+= rx_size
;
975 sis_priv
->stats
.rx_packets
++;
978 entry
= sis_priv
->cur_rx
% NUM_RX_DESC
;
979 rx_status
= sis_priv
->rx_ring
[entry
].cmdsts
;
982 /* refill the Rx buffer, what if the rate of refilling is slower than
984 for (;sis_priv
->cur_rx
- sis_priv
->dirty_rx
> 0; sis_priv
->dirty_rx
++) {
987 entry
= sis_priv
->dirty_rx
% NUM_RX_DESC
;
989 if (sis_priv
->rx_skbuff
[entry
] == NULL
) {
990 if ((skb
= dev_alloc_skb(RX_BUF_SIZE
)) == NULL
) {
991 /* not enough memory for skbuff, this makes a "hole"
992 on the buffer ring, it is not clear how the
993 hardware will react to this kind of degenerated
995 printk(KERN_INFO
"%s: Memory squeeze,"
996 "deferring packet.\n",
998 sis_priv
->stats
.rx_dropped
++;
1002 sis_priv
->rx_skbuff
[entry
] = skb
;
1003 sis_priv
->rx_ring
[entry
].cmdsts
= RX_BUF_SIZE
;
1004 sis_priv
->rx_ring
[entry
].bufptr
= virt_to_bus(skb
->tail
);
1007 /* re-enable the potentially idle receive state matchine */
1008 outl(RxENA
, ioaddr
+ cr
);
1013 /* finish up transmission of packets, check for error condition and free skbuff etc.
1014 Note: This fucntion is called by interrupt handler, don't do "too much" work here */
1015 static void sis900_finish_xmit (struct net_device
*net_dev
)
1017 struct sis900_private
*sis_priv
= (struct sis900_private
*)net_dev
->priv
;
1019 for (; sis_priv
->dirty_tx
< sis_priv
->cur_tx
; sis_priv
->dirty_tx
++) {
1023 entry
= sis_priv
->dirty_tx
% NUM_TX_DESC
;
1024 tx_status
= sis_priv
->tx_ring
[entry
].cmdsts
;
1026 if (tx_status
& OWN
) {
1027 /* The packet is not transmited yet (owned by hardware) !
1028 Note: the interrupt is generated only when Tx Machine
1029 is idle, so this is an almost impossible case */
1033 if (tx_status
& (ABORT
| UNDERRUN
| OWCOLL
)) {
1034 /* packet unsuccessfully transmited */
1035 if (sis900_debug
> 3)
1036 printk(KERN_INFO
"%s: Transmit "
1037 "error, Tx status %8.8x.\n",
1038 net_dev
->name
, tx_status
);
1039 sis_priv
->stats
.tx_errors
++;
1040 if (tx_status
& UNDERRUN
)
1041 sis_priv
->stats
.tx_fifo_errors
++;
1042 if (tx_status
& ABORT
)
1043 sis_priv
->stats
.tx_aborted_errors
++;
1044 if (tx_status
& NOCARRIER
)
1045 sis_priv
->stats
.tx_carrier_errors
++;
1046 if (tx_status
& OWCOLL
)
1047 sis_priv
->stats
.tx_window_errors
++;
1049 /* packet successfully transmited */
1050 sis_priv
->stats
.collisions
+= (tx_status
& COLCNT
) >> 16;
1051 sis_priv
->stats
.tx_bytes
+= tx_status
& DSIZE
;
1052 sis_priv
->stats
.tx_packets
++;
1054 /* Free the original skb. */
1055 dev_kfree_skb_irq(sis_priv
->tx_skbuff
[entry
]);
1056 sis_priv
->tx_skbuff
[entry
] = NULL
;
1057 sis_priv
->tx_ring
[entry
].bufptr
= 0;
1058 sis_priv
->tx_ring
[entry
].cmdsts
= 0;
1061 if (sis_priv
->tx_full
&& test_bit(LINK_STATE_XOFF
, &net_dev
->flags
) &&
1062 sis_priv
->cur_tx
- sis_priv
->dirty_tx
< NUM_TX_DESC
- 4) {
1063 /* The ring is no longer full, clear tbusy, tx_full and
1064 schedule more transmission by marking NET_BH */
1065 sis_priv
->tx_full
= 0;
1066 netif_wake_queue (net_dev
);
1071 sis900_close(struct net_device
*net_dev
)
1073 long ioaddr
= net_dev
->base_addr
;
1074 struct sis900_private
*sis_priv
= (struct sis900_private
*)net_dev
->priv
;
1077 netif_stop_queue(net_dev
);
1079 /* Disable interrupts by clearing the interrupt mask. */
1080 outl(0x0000, ioaddr
+ imr
);
1081 outl(0x0000, ioaddr
+ ier
);
1083 /* Stop the chip's Tx and Rx Status Machine */
1084 outl(RxDIS
| TxDIS
, ioaddr
+ cr
);
1086 del_timer(&sis_priv
->timer
);
1088 free_irq(net_dev
->irq
, net_dev
);
1090 /* Free Tx and RX skbuff */
1091 for (i
= 0; i
< NUM_RX_DESC
; i
++) {
1092 if (sis_priv
->rx_skbuff
[i
] != NULL
)
1093 dev_kfree_skb(sis_priv
->rx_skbuff
[i
]);
1094 sis_priv
->rx_skbuff
[i
] = 0;
1096 for (i
= 0; i
< NUM_TX_DESC
; i
++) {
1097 if (sis_priv
->tx_skbuff
[i
] != NULL
)
1098 dev_kfree_skb(sis_priv
->tx_skbuff
[i
]);
1099 sis_priv
->tx_skbuff
[i
] = 0;
1102 /* Green! Put the chip in low-power mode. */
1109 static int mii_ioctl(struct net_device
*net_dev
, struct ifreq
*rq
, int cmd
)
1111 struct sis900_private
*sis_priv
= (struct sis900_private
*)net_dev
->priv
;
1112 u16
*data
= (u16
*)&rq
->ifr_data
;
1115 case SIOCDEVPRIVATE
: /* Get the address of the PHY in use. */
1116 data
[0] = sis_priv
->mii
->phy_addr
;
1118 case SIOCDEVPRIVATE
+1: /* Read the specified MII register. */
1119 data
[3] = mdio_read(net_dev
, data
[0] & 0x1f, data
[1] & 0x1f);
1121 case SIOCDEVPRIVATE
+2: /* Write the specified MII register */
1124 mdio_write(net_dev
, data
[0] & 0x1f, data
[1] & 0x1f, data
[2]);
1131 static struct enet_statistics
*
1132 sis900_get_stats(struct net_device
*net_dev
)
1134 struct sis900_private
*sis_priv
= (struct sis900_private
*)net_dev
->priv
;
1136 return &sis_priv
->stats
;
1139 /* SiS 900 uses the most sigificant 7 bits to index a 128 bits multicast hash table, which makes
1140 this function a little bit different from other drivers */
1141 static u16
sis900_compute_hashtable_index(u8
*addr
)
1144 /* what is the correct value of the POLYNOMIAL ??
1145 Donald Becker use 0x04C11DB7U
1146 Joseph Zbiciak im14u2c@primenet.com gives me the
1147 correct answer, thank you Joe !! */
1148 #define POLYNOMIAL 0x04C11DB7L
1149 u32 crc
= 0xffffffff, msb
;
1153 for (i
= 0; i
< 6; i
++) {
1155 for (j
= 0; j
< 8; j
++) {
1158 if (msb
^ (byte
& 1)) {
1164 /* leave 7 most siginifant bits */
1165 return ((int)(crc
>> 25));
1168 static void set_rx_mode(struct net_device
*net_dev
)
1170 long ioaddr
= net_dev
->base_addr
;
1171 u16 mc_filter
[8]; /* 128 bits multicast hash table */
1175 if (net_dev
->flags
& IFF_PROMISC
) {
1176 /* Accept any kinds of packets */
1177 rx_mode
= RFPromiscuous
;
1178 for (i
= 0; i
< 8; i
++)
1179 mc_filter
[i
] = 0xffff;
1180 } else if ((net_dev
->mc_count
> multicast_filter_limit
) ||
1181 (net_dev
->flags
& IFF_ALLMULTI
)) {
1182 /* too many multicast addresses or accept all multicast packet */
1183 rx_mode
= RFAAB
| RFAAM
;
1184 for (i
= 0; i
< 8; i
++)
1185 mc_filter
[i
] = 0xffff;
1187 /* Accept Broadcast packet, destination address matchs our MAC address,
1188 use Receive Filter to reject unwanted MCAST packet */
1189 struct dev_mc_list
*mclist
;
1191 for (i
= 0; i
< 8; i
++)
1193 for (i
= 0, mclist
= net_dev
->mc_list
; mclist
&& i
< net_dev
->mc_count
;
1194 i
++, mclist
= mclist
->next
)
1195 set_bit(sis900_compute_hashtable_index(mclist
->dmi_addr
),
1199 /* update Multicast Hash Table in Receive Filter */
1200 for (i
= 0; i
< 8; i
++) {
1201 /* why plus 0x04 ??, That makes the correct value for hash table. */
1202 outl((u32
)(0x00000004+i
) << RFADDR_shift
, ioaddr
+ rfcr
);
1203 outl(mc_filter
[i
], ioaddr
+ rfdr
);
1206 outl(RFEN
| rx_mode
, ioaddr
+ rfcr
);
1208 /* sis900 is capatable of looping back packet at MAC level for debugging purpose */
1209 if (net_dev
->flags
& IFF_LOOPBACK
) {
1211 /* We must disable Tx/Rx before setting loopback mode */
1212 cr_saved
= inl(ioaddr
+ cr
);
1213 outl(cr_saved
| TxDIS
| RxDIS
, ioaddr
+ cr
);
1214 /* enable loopback */
1215 outl(inl(ioaddr
+ txcfg
) | TxMLB
, ioaddr
+ txcfg
);
1216 outl(inl(ioaddr
+ rxcfg
) | RxATX
, ioaddr
+ rxcfg
);
1218 outl(cr_saved
, ioaddr
+ cr
);
1224 static void sis900_reset(struct net_device
*net_dev
)
1226 long ioaddr
= net_dev
->base_addr
;
1228 u32 status
= TxRCMP
| RxRCMP
;
1230 outl(0, ioaddr
+ ier
);
1231 outl(0, ioaddr
+ imr
);
1232 outl(0, ioaddr
+ rfcr
);
1234 outl(RxRESET
| TxRESET
| RESET
, ioaddr
+ cr
);
1236 /* Check that the chip has finished the reset. */
1237 while (status
&& (i
++ < 1000)) {
1238 status
^= (inl(isr
+ ioaddr
) & status
);
1241 outl(PESEL
, ioaddr
+ cfg
);
1244 static void __exit
sis900_cleanup_module(void)
1246 /* No need to check MOD_IN_USE, as sys_delete_module() checks. */
1247 while (root_sis900_dev
) {
1248 struct sis900_private
*sis_priv
=
1249 (struct sis900_private
*)root_sis900_dev
->priv
;
1250 struct net_device
*next_dev
= sis_priv
->next_module
;
1252 unregister_netdev(root_sis900_dev
);
1253 release_region(root_sis900_dev
->base_addr
,
1254 sis_priv
->mac
->io_size
);
1256 kfree(root_sis900_dev
);
1258 root_sis900_dev
= next_dev
;
1262 module_init(sis900_probe
);
1263 module_exit(sis900_cleanup_module
);