5 * Copyright Information:
6 * Copyright SysKonnect 1998,1999.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * The information in this file is provided "AS IS" without warranty.
16 * A Linux device driver supporting the SysKonnect FDDI PCI controller
20 * CG Christoph Goos (cgoos@syskonnect.de)
25 * Address all question to:
28 * The technical manual for the adapters is available from SysKonnect's
29 * web pages: www.syskonnect.com
30 * Goto "Support" and search Knowledge Base for "manual".
32 * Driver Architecture:
33 * The driver architecture is based on the DEC FDDI driver by
34 * Lawrence V. Stefani and several ethernet drivers.
35 * I also used an existing Windows NT miniport driver.
36 * All hardware dependent fuctions are handled by the SysKonnect
38 * The only headerfiles that are directly related to this source
39 * are skfddi.c, h/types.h, h/osdef1st.h, h/targetos.h.
40 * The others belong to the SysKonnect FDDI Hardware Module and
41 * should better not be changed.
43 * Modification History:
44 * Date Name Description
45 * 02-Mar-98 CG Created.
47 * 10-Mar-99 CG Support for 2.2.x added.
48 * 25-Mar-99 CG Corrected IRQ routing for SMP (APIC)
49 * 26-Oct-99 CG Fixed compilation error on 2.2.13
50 * 12-Nov-99 CG Source code release
51 * 22-Nov-99 CG Included in kernel source.
52 * 07-May-00 DM 64 bit fixes, new dma interface
53 * 31-Jul-03 DB Audit copy_*_user in skfp_ioctl
54 * Daniele Bellucci <bellucda@tiscali.it>
55 * 03-Dec-03 SH Convert to PCI device model
57 * Compilation options (-Dxxx):
58 * DRIVERDEBUG print lots of messages to log file
59 * DUMPPACKETS print received/transmitted packets to logfile
61 * Tested cpu architectures:
66 /* Version information string - should be updated prior to */
67 /* each new release!!! */
68 #define VERSION "2.07"
70 static const char * const boot_msg
=
71 "SysKonnect FDDI PCI Adapter driver v" VERSION
" for\n"
72 " SK-55xx/SK-58xx adapters (SK-NET FDDI-FP/UP/LP)";
76 #include <linux/module.h>
77 #include <linux/kernel.h>
78 #include <linux/errno.h>
79 #include <linux/ioport.h>
80 #include <linux/slab.h>
81 #include <linux/interrupt.h>
82 #include <linux/pci.h>
83 #include <linux/netdevice.h>
84 #include <linux/fddidevice.h>
85 #include <linux/skbuff.h>
86 #include <linux/bitops.h>
88 #include <asm/byteorder.h>
90 #include <asm/uaccess.h>
93 #undef ADDR // undo Linux definition
97 #include "h/smtstate.h"
100 // Define module-wide (static) routines
101 static int skfp_driver_init(struct net_device
*dev
);
102 static int skfp_open(struct net_device
*dev
);
103 static int skfp_close(struct net_device
*dev
);
104 static irqreturn_t
skfp_interrupt(int irq
, void *dev_id
);
105 static struct net_device_stats
*skfp_ctl_get_stats(struct net_device
*dev
);
106 static void skfp_ctl_set_multicast_list(struct net_device
*dev
);
107 static void skfp_ctl_set_multicast_list_wo_lock(struct net_device
*dev
);
108 static int skfp_ctl_set_mac_address(struct net_device
*dev
, void *addr
);
109 static int skfp_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
);
110 static int skfp_send_pkt(struct sk_buff
*skb
, struct net_device
*dev
);
111 static void send_queued_packets(struct s_smc
*smc
);
112 static void CheckSourceAddress(unsigned char *frame
, unsigned char *hw_addr
);
113 static void ResetAdapter(struct s_smc
*smc
);
116 // Functions needed by the hardware module
117 void *mac_drv_get_space(struct s_smc
*smc
, u_int size
);
118 void *mac_drv_get_desc_mem(struct s_smc
*smc
, u_int size
);
119 unsigned long mac_drv_virt2phys(struct s_smc
*smc
, void *virt
);
120 unsigned long dma_master(struct s_smc
*smc
, void *virt
, int len
, int flag
);
121 void dma_complete(struct s_smc
*smc
, volatile union s_fp_descr
*descr
,
123 void mac_drv_tx_complete(struct s_smc
*smc
, volatile struct s_smt_fp_txd
*txd
);
124 void llc_restart_tx(struct s_smc
*smc
);
125 void mac_drv_rx_complete(struct s_smc
*smc
, volatile struct s_smt_fp_rxd
*rxd
,
126 int frag_count
, int len
);
127 void mac_drv_requeue_rxd(struct s_smc
*smc
, volatile struct s_smt_fp_rxd
*rxd
,
129 void mac_drv_fill_rxd(struct s_smc
*smc
);
130 void mac_drv_clear_rxd(struct s_smc
*smc
, volatile struct s_smt_fp_rxd
*rxd
,
132 int mac_drv_rx_init(struct s_smc
*smc
, int len
, int fc
, char *look_ahead
,
134 void dump_data(unsigned char *Data
, int length
);
136 // External functions from the hardware module
137 extern u_int
mac_drv_check_space(void);
138 extern int mac_drv_init(struct s_smc
*smc
);
139 extern void hwm_tx_frag(struct s_smc
*smc
, char far
* virt
, u_long phys
,
140 int len
, int frame_status
);
141 extern int hwm_tx_init(struct s_smc
*smc
, u_char fc
, int frag_count
,
142 int frame_len
, int frame_status
);
143 extern void fddi_isr(struct s_smc
*smc
);
144 extern void hwm_rx_frag(struct s_smc
*smc
, char far
* virt
, u_long phys
,
145 int len
, int frame_status
);
146 extern void mac_drv_rx_mode(struct s_smc
*smc
, int mode
);
147 extern void mac_drv_clear_rx_queue(struct s_smc
*smc
);
148 extern void enable_tx_irq(struct s_smc
*smc
, u_short queue
);
150 static struct pci_device_id skfddi_pci_tbl
[] = {
151 { PCI_VENDOR_ID_SK
, PCI_DEVICE_ID_SK_FP
, PCI_ANY_ID
, PCI_ANY_ID
, },
152 { } /* Terminating entry */
154 MODULE_DEVICE_TABLE(pci
, skfddi_pci_tbl
);
155 MODULE_LICENSE("GPL");
156 MODULE_AUTHOR("Mirko Lindner <mlindner@syskonnect.de>");
158 // Define module-wide (static) variables
160 static int num_boards
; /* total number of adapters configured */
162 static const struct net_device_ops skfp_netdev_ops
= {
163 .ndo_open
= skfp_open
,
164 .ndo_stop
= skfp_close
,
165 .ndo_start_xmit
= skfp_send_pkt
,
166 .ndo_get_stats
= skfp_ctl_get_stats
,
167 .ndo_change_mtu
= fddi_change_mtu
,
168 .ndo_set_multicast_list
= skfp_ctl_set_multicast_list
,
169 .ndo_set_mac_address
= skfp_ctl_set_mac_address
,
170 .ndo_do_ioctl
= skfp_ioctl
,
179 * Probes for supported FDDI PCI controllers
185 * pdev - pointer to PCI device information
187 * Functional Description:
188 * This is now called by PCI driver registration process
189 * for each board found.
192 * 0 - This device (fddi0, fddi1, etc) configured successfully
193 * -ENODEV - No devices present, or no SysKonnect FDDI PCI device
194 * present for this device name
198 * Device structures for FDDI adapters (fddi0, fddi1, etc) are
199 * initialized and the board resources are read and stored in
200 * the device structure.
202 static int skfp_init_one(struct pci_dev
*pdev
,
203 const struct pci_device_id
*ent
)
205 struct net_device
*dev
;
206 struct s_smc
*smc
; /* board pointer */
210 pr_debug(KERN_INFO
"entering skfp_init_one\n");
213 printk("%s\n", boot_msg
);
215 err
= pci_enable_device(pdev
);
219 err
= pci_request_regions(pdev
, "skfddi");
223 pci_set_master(pdev
);
226 if (!(pci_resource_flags(pdev
, 0) & IORESOURCE_MEM
)) {
227 printk(KERN_ERR
"skfp: region is not an MMIO resource\n");
232 mem
= ioremap(pci_resource_start(pdev
, 0), 0x4000);
234 if (!(pci_resource_flags(pdev
, 1) & IO_RESOURCE_IO
)) {
235 printk(KERN_ERR
"skfp: region is not PIO resource\n");
240 mem
= ioport_map(pci_resource_start(pdev
, 1), FP_IO_LEN
);
243 printk(KERN_ERR
"skfp: Unable to map register, "
244 "FDDI adapter will be disabled.\n");
249 dev
= alloc_fddidev(sizeof(struct s_smc
));
251 printk(KERN_ERR
"skfp: Unable to allocate fddi device, "
252 "FDDI adapter will be disabled.\n");
257 dev
->irq
= pdev
->irq
;
258 dev
->netdev_ops
= &skfp_netdev_ops
;
260 SET_NETDEV_DEV(dev
, &pdev
->dev
);
262 /* Initialize board structure with bus-specific info */
263 smc
= netdev_priv(dev
);
265 smc
->os
.bus_type
= SK_BUS_TYPE_PCI
;
266 smc
->os
.pdev
= *pdev
;
267 smc
->os
.QueueSkb
= MAX_TX_QUEUE_LEN
;
268 smc
->os
.MaxFrameSize
= MAX_FRAME_SIZE
;
272 smc
->os
.ResetRequested
= FALSE
;
273 skb_queue_head_init(&smc
->os
.SendSkbQueue
);
275 dev
->base_addr
= (unsigned long)mem
;
277 err
= skfp_driver_init(dev
);
281 err
= register_netdev(dev
);
286 pci_set_drvdata(pdev
, dev
);
288 if ((pdev
->subsystem_device
& 0xff00) == 0x5500 ||
289 (pdev
->subsystem_device
& 0xff00) == 0x5800)
290 printk("%s: SysKonnect FDDI PCI adapter"
291 " found (SK-%04X)\n", dev
->name
,
292 pdev
->subsystem_device
);
294 printk("%s: FDDI PCI adapter found\n", dev
->name
);
298 if (smc
->os
.SharedMemAddr
)
299 pci_free_consistent(pdev
, smc
->os
.SharedMemSize
,
300 smc
->os
.SharedMemAddr
,
301 smc
->os
.SharedMemDMA
);
302 pci_free_consistent(pdev
, MAX_FRAME_SIZE
,
303 smc
->os
.LocalRxBuffer
, smc
->os
.LocalRxBufferDMA
);
313 pci_release_regions(pdev
);
315 pci_disable_device(pdev
);
320 * Called for each adapter board from pci_unregister_driver
322 static void __devexit
skfp_remove_one(struct pci_dev
*pdev
)
324 struct net_device
*p
= pci_get_drvdata(pdev
);
325 struct s_smc
*lp
= netdev_priv(p
);
327 unregister_netdev(p
);
329 if (lp
->os
.SharedMemAddr
) {
330 pci_free_consistent(&lp
->os
.pdev
,
331 lp
->os
.SharedMemSize
,
332 lp
->os
.SharedMemAddr
,
333 lp
->os
.SharedMemDMA
);
334 lp
->os
.SharedMemAddr
= NULL
;
336 if (lp
->os
.LocalRxBuffer
) {
337 pci_free_consistent(&lp
->os
.pdev
,
339 lp
->os
.LocalRxBuffer
,
340 lp
->os
.LocalRxBufferDMA
);
341 lp
->os
.LocalRxBuffer
= NULL
;
346 ioport_unmap(lp
->hw
.iop
);
348 pci_release_regions(pdev
);
351 pci_disable_device(pdev
);
352 pci_set_drvdata(pdev
, NULL
);
356 * ====================
357 * = skfp_driver_init =
358 * ====================
361 * Initializes remaining adapter board structure information
362 * and makes sure adapter is in a safe state prior to skfp_open().
368 * dev - pointer to device information
370 * Functional Description:
371 * This function allocates additional resources such as the host memory
372 * blocks needed by the adapter.
373 * The adapter is also reset. The OS must call skfp_open() to open
374 * the adapter and bring it on-line.
377 * 0 - initialization succeeded
378 * -1 - initialization failed
380 static int skfp_driver_init(struct net_device
*dev
)
382 struct s_smc
*smc
= netdev_priv(dev
);
383 skfddi_priv
*bp
= &smc
->os
;
386 pr_debug(KERN_INFO
"entering skfp_driver_init\n");
388 // set the io address in private structures
389 bp
->base_addr
= dev
->base_addr
;
391 // Get the interrupt level from the PCI Configuration Table
392 smc
->hw
.irq
= dev
->irq
;
394 spin_lock_init(&bp
->DriverLock
);
396 // Allocate invalid frame
397 bp
->LocalRxBuffer
= pci_alloc_consistent(&bp
->pdev
, MAX_FRAME_SIZE
, &bp
->LocalRxBufferDMA
);
398 if (!bp
->LocalRxBuffer
) {
399 printk("could not allocate mem for ");
400 printk("LocalRxBuffer: %d byte\n", MAX_FRAME_SIZE
);
404 // Determine the required size of the 'shared' memory area.
405 bp
->SharedMemSize
= mac_drv_check_space();
406 pr_debug(KERN_INFO
"Memory for HWM: %ld\n", bp
->SharedMemSize
);
407 if (bp
->SharedMemSize
> 0) {
408 bp
->SharedMemSize
+= 16; // for descriptor alignment
410 bp
->SharedMemAddr
= pci_alloc_consistent(&bp
->pdev
,
413 if (!bp
->SharedMemSize
) {
414 printk("could not allocate mem for ");
415 printk("hardware module: %ld byte\n",
419 bp
->SharedMemHeap
= 0; // Nothing used yet.
422 bp
->SharedMemAddr
= NULL
;
423 bp
->SharedMemHeap
= 0;
424 } // SharedMemSize > 0
426 memset(bp
->SharedMemAddr
, 0, bp
->SharedMemSize
);
428 card_stop(smc
); // Reset adapter.
430 pr_debug(KERN_INFO
"mac_drv_init()..\n");
431 if (mac_drv_init(smc
) != 0) {
432 pr_debug(KERN_INFO
"mac_drv_init() failed.\n");
435 read_address(smc
, NULL
);
436 pr_debug(KERN_INFO
"HW-Addr: %02x %02x %02x %02x %02x %02x\n",
437 smc
->hw
.fddi_canon_addr
.a
[0],
438 smc
->hw
.fddi_canon_addr
.a
[1],
439 smc
->hw
.fddi_canon_addr
.a
[2],
440 smc
->hw
.fddi_canon_addr
.a
[3],
441 smc
->hw
.fddi_canon_addr
.a
[4],
442 smc
->hw
.fddi_canon_addr
.a
[5]);
443 memcpy(dev
->dev_addr
, smc
->hw
.fddi_canon_addr
.a
, 6);
445 smt_reset_defaults(smc
, 0);
450 if (bp
->SharedMemAddr
) {
451 pci_free_consistent(&bp
->pdev
,
455 bp
->SharedMemAddr
= NULL
;
457 if (bp
->LocalRxBuffer
) {
458 pci_free_consistent(&bp
->pdev
, MAX_FRAME_SIZE
,
459 bp
->LocalRxBuffer
, bp
->LocalRxBufferDMA
);
460 bp
->LocalRxBuffer
= NULL
;
463 } // skfp_driver_init
478 * dev - pointer to device information
480 * Functional Description:
481 * This function brings the adapter to an operational state.
484 * 0 - Adapter was successfully opened
485 * -EAGAIN - Could not register IRQ
487 static int skfp_open(struct net_device
*dev
)
489 struct s_smc
*smc
= netdev_priv(dev
);
492 pr_debug(KERN_INFO
"entering skfp_open\n");
493 /* Register IRQ - support shared interrupts by passing device ptr */
494 err
= request_irq(dev
->irq
, skfp_interrupt
, IRQF_SHARED
,
500 * Set current address to factory MAC address
502 * Note: We've already done this step in skfp_driver_init.
503 * However, it's possible that a user has set a node
504 * address override, then closed and reopened the
505 * adapter. Unless we reset the device address field
506 * now, we'll continue to use the existing modified
509 read_address(smc
, NULL
);
510 memcpy(dev
->dev_addr
, smc
->hw
.fddi_canon_addr
.a
, 6);
516 /* Clear local multicast address tables */
517 mac_clear_multicast(smc
);
519 /* Disable promiscuous filter settings */
520 mac_drv_rx_mode(smc
, RX_DISABLE_PROMISC
);
522 netif_start_queue(dev
);
533 * Closes the device/module.
539 * dev - pointer to device information
541 * Functional Description:
542 * This routine closes the adapter and brings it to a safe state.
543 * The interrupt service routine is deregistered with the OS.
544 * The adapter can be opened again with another call to skfp_open().
550 * No further requests for this adapter are made after this routine is
551 * called. skfp_open() can be called to reset and reinitialize the
554 static int skfp_close(struct net_device
*dev
)
556 struct s_smc
*smc
= netdev_priv(dev
);
557 skfddi_priv
*bp
= &smc
->os
;
560 smt_reset_defaults(smc
, 1);
562 mac_drv_clear_tx_queue(smc
);
563 mac_drv_clear_rx_queue(smc
);
565 netif_stop_queue(dev
);
566 /* Deregister (free) IRQ */
567 free_irq(dev
->irq
, dev
);
569 skb_queue_purge(&bp
->SendSkbQueue
);
570 bp
->QueueSkb
= MAX_TX_QUEUE_LEN
;
582 * Interrupt processing routine
588 * irq - interrupt vector
589 * dev_id - pointer to device information
591 * Functional Description:
592 * This routine calls the interrupt processing routine for this adapter. It
593 * disables and reenables adapter interrupts, as appropriate. We can support
594 * shared interrupts since the incoming dev_id pointer provides our device
595 * structure context. All the real work is done in the hardware module.
601 * The interrupt acknowledgement at the hardware level (eg. ACKing the PIC
602 * on Intel-based systems) is done by the operating system outside this
605 * System interrupts are enabled through this call.
608 * Interrupts are disabled, then reenabled at the adapter.
611 static irqreturn_t
skfp_interrupt(int irq
, void *dev_id
)
613 struct net_device
*dev
= dev_id
;
614 struct s_smc
*smc
; /* private board structure pointer */
617 smc
= netdev_priv(dev
);
620 // IRQs enabled or disabled ?
621 if (inpd(ADDR(B0_IMSK
)) == 0) {
622 // IRQs are disabled: must be shared interrupt
625 // Note: At this point, IRQs are enabled.
626 if ((inpd(ISR_A
) & smc
->hw
.is_imask
) == 0) { // IRQ?
627 // Adapter did not issue an IRQ: must be shared interrupt
630 CLI_FBI(); // Disable IRQs from our adapter.
631 spin_lock(&bp
->DriverLock
);
633 // Call interrupt handler in hardware module (HWM).
636 if (smc
->os
.ResetRequested
) {
638 smc
->os
.ResetRequested
= FALSE
;
640 spin_unlock(&bp
->DriverLock
);
641 STI_FBI(); // Enable IRQs from our adapter.
648 * ======================
649 * = skfp_ctl_get_stats =
650 * ======================
653 * Get statistics for FDDI adapter
656 * Pointer to FDDI statistics structure
659 * dev - pointer to device information
661 * Functional Description:
662 * Gets current MIB objects from adapter, then
663 * returns FDDI statistics structure as defined
666 * Note: Since the FDDI statistics structure is
667 * still new and the device structure doesn't
668 * have an FDDI-specific get statistics handler,
669 * we'll return the FDDI statistics structure as
670 * a pointer to an Ethernet statistics structure.
671 * That way, at least the first part of the statistics
672 * structure can be decoded properly.
673 * We'll have to pay attention to this routine as the
674 * device structure becomes more mature and LAN media
678 static struct net_device_stats
*skfp_ctl_get_stats(struct net_device
*dev
)
680 struct s_smc
*bp
= netdev_priv(dev
);
682 /* Fill the bp->stats structure with driver-maintained counters */
684 bp
->os
.MacStat
.port_bs_flag
[0] = 0x1234;
685 bp
->os
.MacStat
.port_bs_flag
[1] = 0x5678;
686 // goos: need to fill out fddi statistic
688 /* Get FDDI SMT MIB objects */
690 /* Fill the bp->stats structure with the SMT MIB object values */
692 memcpy(bp
->stats
.smt_station_id
, &bp
->cmd_rsp_virt
->smt_mib_get
.smt_station_id
, sizeof(bp
->cmd_rsp_virt
->smt_mib_get
.smt_station_id
));
693 bp
->stats
.smt_op_version_id
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_op_version_id
;
694 bp
->stats
.smt_hi_version_id
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_hi_version_id
;
695 bp
->stats
.smt_lo_version_id
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_lo_version_id
;
696 memcpy(bp
->stats
.smt_user_data
, &bp
->cmd_rsp_virt
->smt_mib_get
.smt_user_data
, sizeof(bp
->cmd_rsp_virt
->smt_mib_get
.smt_user_data
));
697 bp
->stats
.smt_mib_version_id
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_mib_version_id
;
698 bp
->stats
.smt_mac_cts
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_mac_ct
;
699 bp
->stats
.smt_non_master_cts
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_non_master_ct
;
700 bp
->stats
.smt_master_cts
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_master_ct
;
701 bp
->stats
.smt_available_paths
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_available_paths
;
702 bp
->stats
.smt_config_capabilities
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_config_capabilities
;
703 bp
->stats
.smt_config_policy
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_config_policy
;
704 bp
->stats
.smt_connection_policy
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_connection_policy
;
705 bp
->stats
.smt_t_notify
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_t_notify
;
706 bp
->stats
.smt_stat_rpt_policy
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_stat_rpt_policy
;
707 bp
->stats
.smt_trace_max_expiration
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_trace_max_expiration
;
708 bp
->stats
.smt_bypass_present
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_bypass_present
;
709 bp
->stats
.smt_ecm_state
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_ecm_state
;
710 bp
->stats
.smt_cf_state
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_cf_state
;
711 bp
->stats
.smt_remote_disconnect_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_remote_disconnect_flag
;
712 bp
->stats
.smt_station_status
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_station_status
;
713 bp
->stats
.smt_peer_wrap_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_peer_wrap_flag
;
714 bp
->stats
.smt_time_stamp
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_msg_time_stamp
.ls
;
715 bp
->stats
.smt_transition_time_stamp
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_transition_time_stamp
.ls
;
716 bp
->stats
.mac_frame_status_functions
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_frame_status_functions
;
717 bp
->stats
.mac_t_max_capability
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_t_max_capability
;
718 bp
->stats
.mac_tvx_capability
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_tvx_capability
;
719 bp
->stats
.mac_available_paths
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_available_paths
;
720 bp
->stats
.mac_current_path
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_current_path
;
721 memcpy(bp
->stats
.mac_upstream_nbr
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_upstream_nbr
, FDDI_K_ALEN
);
722 memcpy(bp
->stats
.mac_downstream_nbr
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_downstream_nbr
, FDDI_K_ALEN
);
723 memcpy(bp
->stats
.mac_old_upstream_nbr
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_old_upstream_nbr
, FDDI_K_ALEN
);
724 memcpy(bp
->stats
.mac_old_downstream_nbr
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_old_downstream_nbr
, FDDI_K_ALEN
);
725 bp
->stats
.mac_dup_address_test
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_dup_address_test
;
726 bp
->stats
.mac_requested_paths
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_requested_paths
;
727 bp
->stats
.mac_downstream_port_type
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_downstream_port_type
;
728 memcpy(bp
->stats
.mac_smt_address
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_smt_address
, FDDI_K_ALEN
);
729 bp
->stats
.mac_t_req
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_t_req
;
730 bp
->stats
.mac_t_neg
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_t_neg
;
731 bp
->stats
.mac_t_max
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_t_max
;
732 bp
->stats
.mac_tvx_value
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_tvx_value
;
733 bp
->stats
.mac_frame_error_threshold
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_frame_error_threshold
;
734 bp
->stats
.mac_frame_error_ratio
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_frame_error_ratio
;
735 bp
->stats
.mac_rmt_state
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_rmt_state
;
736 bp
->stats
.mac_da_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_da_flag
;
737 bp
->stats
.mac_una_da_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_unda_flag
;
738 bp
->stats
.mac_frame_error_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_frame_error_flag
;
739 bp
->stats
.mac_ma_unitdata_available
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_ma_unitdata_available
;
740 bp
->stats
.mac_hardware_present
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_hardware_present
;
741 bp
->stats
.mac_ma_unitdata_enable
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_ma_unitdata_enable
;
742 bp
->stats
.path_tvx_lower_bound
= bp
->cmd_rsp_virt
->smt_mib_get
.path_tvx_lower_bound
;
743 bp
->stats
.path_t_max_lower_bound
= bp
->cmd_rsp_virt
->smt_mib_get
.path_t_max_lower_bound
;
744 bp
->stats
.path_max_t_req
= bp
->cmd_rsp_virt
->smt_mib_get
.path_max_t_req
;
745 memcpy(bp
->stats
.path_configuration
, &bp
->cmd_rsp_virt
->smt_mib_get
.path_configuration
, sizeof(bp
->cmd_rsp_virt
->smt_mib_get
.path_configuration
));
746 bp
->stats
.port_my_type
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_my_type
[0];
747 bp
->stats
.port_my_type
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_my_type
[1];
748 bp
->stats
.port_neighbor_type
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_neighbor_type
[0];
749 bp
->stats
.port_neighbor_type
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_neighbor_type
[1];
750 bp
->stats
.port_connection_policies
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connection_policies
[0];
751 bp
->stats
.port_connection_policies
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connection_policies
[1];
752 bp
->stats
.port_mac_indicated
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_mac_indicated
[0];
753 bp
->stats
.port_mac_indicated
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_mac_indicated
[1];
754 bp
->stats
.port_current_path
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_current_path
[0];
755 bp
->stats
.port_current_path
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_current_path
[1];
756 memcpy(&bp
->stats
.port_requested_paths
[0 * 3], &bp
->cmd_rsp_virt
->smt_mib_get
.port_requested_paths
[0], 3);
757 memcpy(&bp
->stats
.port_requested_paths
[1 * 3], &bp
->cmd_rsp_virt
->smt_mib_get
.port_requested_paths
[1], 3);
758 bp
->stats
.port_mac_placement
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_mac_placement
[0];
759 bp
->stats
.port_mac_placement
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_mac_placement
[1];
760 bp
->stats
.port_available_paths
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_available_paths
[0];
761 bp
->stats
.port_available_paths
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_available_paths
[1];
762 bp
->stats
.port_pmd_class
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pmd_class
[0];
763 bp
->stats
.port_pmd_class
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pmd_class
[1];
764 bp
->stats
.port_connection_capabilities
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connection_capabilities
[0];
765 bp
->stats
.port_connection_capabilities
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connection_capabilities
[1];
766 bp
->stats
.port_bs_flag
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_bs_flag
[0];
767 bp
->stats
.port_bs_flag
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_bs_flag
[1];
768 bp
->stats
.port_ler_estimate
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_estimate
[0];
769 bp
->stats
.port_ler_estimate
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_estimate
[1];
770 bp
->stats
.port_ler_cutoff
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_cutoff
[0];
771 bp
->stats
.port_ler_cutoff
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_cutoff
[1];
772 bp
->stats
.port_ler_alarm
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_alarm
[0];
773 bp
->stats
.port_ler_alarm
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_alarm
[1];
774 bp
->stats
.port_connect_state
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connect_state
[0];
775 bp
->stats
.port_connect_state
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connect_state
[1];
776 bp
->stats
.port_pcm_state
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pcm_state
[0];
777 bp
->stats
.port_pcm_state
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pcm_state
[1];
778 bp
->stats
.port_pc_withhold
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pc_withhold
[0];
779 bp
->stats
.port_pc_withhold
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pc_withhold
[1];
780 bp
->stats
.port_ler_flag
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_flag
[0];
781 bp
->stats
.port_ler_flag
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_flag
[1];
782 bp
->stats
.port_hardware_present
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_hardware_present
[0];
783 bp
->stats
.port_hardware_present
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_hardware_present
[1];
786 /* Fill the bp->stats structure with the FDDI counter values */
788 bp
->stats
.mac_frame_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.frame_cnt
.ls
;
789 bp
->stats
.mac_copied_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.copied_cnt
.ls
;
790 bp
->stats
.mac_transmit_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.transmit_cnt
.ls
;
791 bp
->stats
.mac_error_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.error_cnt
.ls
;
792 bp
->stats
.mac_lost_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lost_cnt
.ls
;
793 bp
->stats
.port_lct_fail_cts
[0] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lct_rejects
[0].ls
;
794 bp
->stats
.port_lct_fail_cts
[1] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lct_rejects
[1].ls
;
795 bp
->stats
.port_lem_reject_cts
[0] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lem_rejects
[0].ls
;
796 bp
->stats
.port_lem_reject_cts
[1] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lem_rejects
[1].ls
;
797 bp
->stats
.port_lem_cts
[0] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.link_errors
[0].ls
;
798 bp
->stats
.port_lem_cts
[1] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.link_errors
[1].ls
;
801 return ((struct net_device_stats
*) &bp
->os
.MacStat
);
806 * ==============================
807 * = skfp_ctl_set_multicast_list =
808 * ==============================
811 * Enable/Disable LLC frame promiscuous mode reception
812 * on the adapter and/or update multicast address table.
818 * dev - pointer to device information
820 * Functional Description:
821 * This function acquires the driver lock and only calls
822 * skfp_ctl_set_multicast_list_wo_lock then.
823 * This routine follows a fairly simple algorithm for setting the
824 * adapter filters and CAM:
826 * if IFF_PROMISC flag is set
827 * enable promiscuous mode
829 * disable promiscuous mode
830 * if number of multicast addresses <= max. multicast number
831 * add mc addresses to adapter table
833 * enable promiscuous mode
834 * update adapter filters
837 * Multicast addresses are presented in canonical (LSB) format.
840 * On-board adapter filters are updated.
842 static void skfp_ctl_set_multicast_list(struct net_device
*dev
)
844 struct s_smc
*smc
= netdev_priv(dev
);
845 skfddi_priv
*bp
= &smc
->os
;
848 spin_lock_irqsave(&bp
->DriverLock
, Flags
);
849 skfp_ctl_set_multicast_list_wo_lock(dev
);
850 spin_unlock_irqrestore(&bp
->DriverLock
, Flags
);
852 } // skfp_ctl_set_multicast_list
856 static void skfp_ctl_set_multicast_list_wo_lock(struct net_device
*dev
)
858 struct s_smc
*smc
= netdev_priv(dev
);
859 struct dev_mc_list
*dmi
; /* ptr to multicast addr entry */
862 /* Enable promiscuous mode, if necessary */
863 if (dev
->flags
& IFF_PROMISC
) {
864 mac_drv_rx_mode(smc
, RX_ENABLE_PROMISC
);
865 pr_debug(KERN_INFO
"PROMISCUOUS MODE ENABLED\n");
867 /* Else, update multicast address table */
869 mac_drv_rx_mode(smc
, RX_DISABLE_PROMISC
);
870 pr_debug(KERN_INFO
"PROMISCUOUS MODE DISABLED\n");
872 // Reset all MC addresses
873 mac_clear_multicast(smc
);
874 mac_drv_rx_mode(smc
, RX_DISABLE_ALLMULTI
);
876 if (dev
->flags
& IFF_ALLMULTI
) {
877 mac_drv_rx_mode(smc
, RX_ENABLE_ALLMULTI
);
878 pr_debug(KERN_INFO
"ENABLE ALL MC ADDRESSES\n");
879 } else if (dev
->mc_count
> 0) {
880 if (dev
->mc_count
<= FPMAX_MULTICAST
) {
881 /* use exact filtering */
883 // point to first multicast addr
886 for (i
= 0; i
< dev
->mc_count
; i
++) {
887 mac_add_multicast(smc
,
888 (struct fddi_addr
*)dmi
->dmi_addr
,
891 pr_debug(KERN_INFO
"ENABLE MC ADDRESS:");
892 pr_debug(" %02x %02x %02x ",
896 pr_debug("%02x %02x %02x\n",
903 } else { // more MC addresses than HW supports
905 mac_drv_rx_mode(smc
, RX_ENABLE_ALLMULTI
);
906 pr_debug(KERN_INFO
"ENABLE ALL MC ADDRESSES\n");
908 } else { // no MC addresses
910 pr_debug(KERN_INFO
"DISABLE ALL MC ADDRESSES\n");
913 /* Update adapter filters */
914 mac_update_multicast(smc
);
917 } // skfp_ctl_set_multicast_list_wo_lock
921 * ===========================
922 * = skfp_ctl_set_mac_address =
923 * ===========================
926 * set new mac address on adapter and update dev_addr field in device table.
932 * dev - pointer to device information
933 * addr - pointer to sockaddr structure containing unicast address to set
936 * The address pointed to by addr->sa_data is a valid unicast
937 * address and is presented in canonical (LSB) format.
939 static int skfp_ctl_set_mac_address(struct net_device
*dev
, void *addr
)
941 struct s_smc
*smc
= netdev_priv(dev
);
942 struct sockaddr
*p_sockaddr
= (struct sockaddr
*) addr
;
943 skfddi_priv
*bp
= &smc
->os
;
947 memcpy(dev
->dev_addr
, p_sockaddr
->sa_data
, FDDI_K_ALEN
);
948 spin_lock_irqsave(&bp
->DriverLock
, Flags
);
950 spin_unlock_irqrestore(&bp
->DriverLock
, Flags
);
952 return (0); /* always return zero */
953 } // skfp_ctl_set_mac_address
963 * Perform IOCTL call functions here. Some are privileged operations and the
964 * effective uid is checked in those cases.
972 * dev - pointer to device information
973 * rq - pointer to ioctl request structure
979 static int skfp_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
)
981 struct s_smc
*smc
= netdev_priv(dev
);
982 skfddi_priv
*lp
= &smc
->os
;
983 struct s_skfp_ioctl ioc
;
986 if (copy_from_user(&ioc
, rq
->ifr_data
, sizeof(struct s_skfp_ioctl
)))
990 case SKFP_GET_STATS
: /* Get the driver statistics */
991 ioc
.len
= sizeof(lp
->MacStat
);
992 status
= copy_to_user(ioc
.data
, skfp_ctl_get_stats(dev
), ioc
.len
)
995 case SKFP_CLR_STATS
: /* Zero out the driver statistics */
996 if (!capable(CAP_NET_ADMIN
)) {
999 memset(&lp
->MacStat
, 0, sizeof(lp
->MacStat
));
1003 printk("ioctl for %s: unknow cmd: %04x\n", dev
->name
, ioc
.cmd
);
1004 status
= -EOPNOTSUPP
;
1013 * =====================
1015 * =====================
1018 * Queues a packet for transmission and try to transmit it.
1024 * skb - pointer to sk_buff to queue for transmission
1025 * dev - pointer to device information
1027 * Functional Description:
1028 * Here we assume that an incoming skb transmit request
1029 * is contained in a single physically contiguous buffer
1030 * in which the virtual address of the start of packet
1031 * (skb->data) can be converted to a physical address
1032 * by using pci_map_single().
1034 * We have an internal queue for packets we can not send
1035 * immediately. Packets in this queue can be given to the
1036 * adapter if transmit buffers are freed.
1038 * We can't free the skb until after it's been DMA'd
1039 * out by the adapter, so we'll keep it in the driver and
1040 * return it in mac_drv_tx_complete.
1043 * 0 - driver has queued and/or sent packet
1044 * 1 - caller should requeue the sk_buff for later transmission
1047 * The entire packet is stored in one physically
1048 * contiguous buffer which is not cached and whose
1049 * 32-bit physical address can be determined.
1051 * It's vital that this routine is NOT reentered for the
1052 * same board and that the OS is not in another section of
1053 * code (eg. skfp_interrupt) for the same board on a
1059 static int skfp_send_pkt(struct sk_buff
*skb
, struct net_device
*dev
)
1061 struct s_smc
*smc
= netdev_priv(dev
);
1062 skfddi_priv
*bp
= &smc
->os
;
1064 pr_debug(KERN_INFO
"skfp_send_pkt\n");
1067 * Verify that incoming transmit request is OK
1069 * Note: The packet size check is consistent with other
1070 * Linux device drivers, although the correct packet
1071 * size should be verified before calling the
1075 if (!(skb
->len
>= FDDI_K_LLC_ZLEN
&& skb
->len
<= FDDI_K_LLC_LEN
)) {
1076 bp
->MacStat
.gen
.tx_errors
++; /* bump error counter */
1077 // dequeue packets from xmt queue and send them
1078 netif_start_queue(dev
);
1080 return (0); /* return "success" */
1082 if (bp
->QueueSkb
== 0) { // return with tbusy set: queue full
1084 netif_stop_queue(dev
);
1085 return NETDEV_TX_BUSY
;
1088 skb_queue_tail(&bp
->SendSkbQueue
, skb
);
1089 send_queued_packets(netdev_priv(dev
));
1090 if (bp
->QueueSkb
== 0) {
1091 netif_stop_queue(dev
);
1093 dev
->trans_start
= jiffies
;
1100 * =======================
1101 * = send_queued_packets =
1102 * =======================
1105 * Send packets from the driver queue as long as there are some and
1106 * transmit resources are available.
1112 * smc - pointer to smc (adapter) structure
1114 * Functional Description:
1115 * Take a packet from queue if there is any. If not, then we are done.
1116 * Check if there are resources to send the packet. If not, requeue it
1118 * Set packet descriptor flags and give packet to adapter.
1119 * Check if any send resources can be freed (we do not use the
1120 * transmit complete interrupt).
1122 static void send_queued_packets(struct s_smc
*smc
)
1124 skfddi_priv
*bp
= &smc
->os
;
1125 struct sk_buff
*skb
;
1128 struct s_smt_fp_txd
*txd
; // Current TxD.
1129 dma_addr_t dma_address
;
1130 unsigned long Flags
;
1132 int frame_status
; // HWM tx frame status.
1134 pr_debug(KERN_INFO
"send queued packets\n");
1136 // send first buffer from queue
1137 skb
= skb_dequeue(&bp
->SendSkbQueue
);
1140 pr_debug(KERN_INFO
"queue empty\n");
1144 spin_lock_irqsave(&bp
->DriverLock
, Flags
);
1146 queue
= (fc
& FC_SYNC_BIT
) ? QUEUE_S
: QUEUE_A0
;
1148 // Check if the frame may/must be sent as a synchronous frame.
1150 if ((fc
& ~(FC_SYNC_BIT
| FC_LLC_PRIOR
)) == FC_ASYNC_LLC
) {
1151 // It's an LLC frame.
1152 if (!smc
->ess
.sync_bw_available
)
1153 fc
&= ~FC_SYNC_BIT
; // No bandwidth available.
1155 else { // Bandwidth is available.
1157 if (smc
->mib
.fddiESSSynchTxMode
) {
1158 // Send as sync. frame.
1164 frame_status
= hwm_tx_init(smc
, fc
, 1, skb
->len
, queue
);
1166 if ((frame_status
& (LOC_TX
| LAN_TX
)) == 0) {
1167 // Unable to send the frame.
1169 if ((frame_status
& RING_DOWN
) != 0) {
1171 pr_debug("Tx attempt while ring down.\n");
1172 } else if ((frame_status
& OUT_OF_TXD
) != 0) {
1173 pr_debug("%s: out of TXDs.\n", bp
->dev
->name
);
1175 pr_debug("%s: out of transmit resources",
1179 // Note: We will retry the operation as soon as
1180 // transmit resources become available.
1181 skb_queue_head(&bp
->SendSkbQueue
, skb
);
1182 spin_unlock_irqrestore(&bp
->DriverLock
, Flags
);
1183 return; // Packet has been queued.
1185 } // if (unable to send frame)
1187 bp
->QueueSkb
++; // one packet less in local queue
1189 // source address in packet ?
1190 CheckSourceAddress(skb
->data
, smc
->hw
.fddi_canon_addr
.a
);
1192 txd
= (struct s_smt_fp_txd
*) HWM_GET_CURR_TXD(smc
, queue
);
1194 dma_address
= pci_map_single(&bp
->pdev
, skb
->data
,
1195 skb
->len
, PCI_DMA_TODEVICE
);
1196 if (frame_status
& LAN_TX
) {
1197 txd
->txd_os
.skb
= skb
; // save skb
1198 txd
->txd_os
.dma_addr
= dma_address
; // save dma mapping
1200 hwm_tx_frag(smc
, skb
->data
, dma_address
, skb
->len
,
1201 frame_status
| FIRST_FRAG
| LAST_FRAG
| EN_IRQ_EOF
);
1203 if (!(frame_status
& LAN_TX
)) { // local only frame
1204 pci_unmap_single(&bp
->pdev
, dma_address
,
1205 skb
->len
, PCI_DMA_TODEVICE
);
1206 dev_kfree_skb_irq(skb
);
1208 spin_unlock_irqrestore(&bp
->DriverLock
, Flags
);
1211 return; // never reached
1213 } // send_queued_packets
1216 /************************
1218 * CheckSourceAddress
1220 * Verify if the source address is set. Insert it if necessary.
1222 ************************/
1223 static void CheckSourceAddress(unsigned char *frame
, unsigned char *hw_addr
)
1225 unsigned char SRBit
;
1227 if ((((unsigned long) frame
[1 + 6]) & ~0x01) != 0) // source routing bit
1230 if ((unsigned short) frame
[1 + 10] != 0)
1232 SRBit
= frame
[1 + 6] & 0x01;
1233 memcpy(&frame
[1 + 6], hw_addr
, 6);
1235 } // CheckSourceAddress
1238 /************************
1242 * Reset the adapter and bring it back to operational mode.
1244 * smc - A pointer to the SMT context struct.
1248 ************************/
1249 static void ResetAdapter(struct s_smc
*smc
)
1252 pr_debug(KERN_INFO
"[fddi: ResetAdapter]\n");
1254 // Stop the adapter.
1256 card_stop(smc
); // Stop all activity.
1258 // Clear the transmit and receive descriptor queues.
1259 mac_drv_clear_tx_queue(smc
);
1260 mac_drv_clear_rx_queue(smc
);
1262 // Restart the adapter.
1264 smt_reset_defaults(smc
, 1); // Initialize the SMT module.
1266 init_smt(smc
, (smc
->os
.dev
)->dev_addr
); // Initialize the hardware.
1268 smt_online(smc
, 1); // Insert into the ring again.
1271 // Restore original receive mode (multicasts, promiscuous, etc.).
1272 skfp_ctl_set_multicast_list_wo_lock(smc
->os
.dev
);
1276 //--------------- functions called by hardware module ----------------
1278 /************************
1282 * The hardware driver calls this routine when the transmit complete
1283 * interrupt bits (end of frame) for the synchronous or asynchronous
1286 * NOTE The hardware driver calls this function also if no packets are queued.
1287 * The routine must be able to handle this case.
1289 * smc - A pointer to the SMT context struct.
1293 ************************/
1294 void llc_restart_tx(struct s_smc
*smc
)
1296 skfddi_priv
*bp
= &smc
->os
;
1298 pr_debug(KERN_INFO
"[llc_restart_tx]\n");
1300 // Try to send queued packets
1301 spin_unlock(&bp
->DriverLock
);
1302 send_queued_packets(smc
);
1303 spin_lock(&bp
->DriverLock
);
1304 netif_start_queue(bp
->dev
);// system may send again if it was blocked
1309 /************************
1313 * The hardware module calls this function to allocate the memory
1314 * for the SMT MBufs if the define MB_OUTSIDE_SMC is specified.
1316 * smc - A pointer to the SMT context struct.
1318 * size - Size of memory in bytes to allocate.
1320 * != 0 A pointer to the virtual address of the allocated memory.
1321 * == 0 Allocation error.
1323 ************************/
1324 void *mac_drv_get_space(struct s_smc
*smc
, unsigned int size
)
1328 pr_debug(KERN_INFO
"mac_drv_get_space (%d bytes), ", size
);
1329 virt
= (void *) (smc
->os
.SharedMemAddr
+ smc
->os
.SharedMemHeap
);
1331 if ((smc
->os
.SharedMemHeap
+ size
) > smc
->os
.SharedMemSize
) {
1332 printk("Unexpected SMT memory size requested: %d\n", size
);
1335 smc
->os
.SharedMemHeap
+= size
; // Move heap pointer.
1337 pr_debug(KERN_INFO
"mac_drv_get_space end\n");
1338 pr_debug(KERN_INFO
"virt addr: %lx\n", (ulong
) virt
);
1339 pr_debug(KERN_INFO
"bus addr: %lx\n", (ulong
)
1340 (smc
->os
.SharedMemDMA
+
1341 ((char *) virt
- (char *)smc
->os
.SharedMemAddr
)));
1343 } // mac_drv_get_space
1346 /************************
1348 * mac_drv_get_desc_mem
1350 * This function is called by the hardware dependent module.
1351 * It allocates the memory for the RxD and TxD descriptors.
1353 * This memory must be non-cached, non-movable and non-swappable.
1354 * This memory should start at a physical page boundary.
1356 * smc - A pointer to the SMT context struct.
1358 * size - Size of memory in bytes to allocate.
1360 * != 0 A pointer to the virtual address of the allocated memory.
1361 * == 0 Allocation error.
1363 ************************/
1364 void *mac_drv_get_desc_mem(struct s_smc
*smc
, unsigned int size
)
1369 pr_debug(KERN_INFO
"mac_drv_get_desc_mem\n");
1371 // Descriptor memory must be aligned on 16-byte boundary.
1373 virt
= mac_drv_get_space(smc
, size
);
1375 size
= (u_int
) (16 - (((unsigned long) virt
) & 15UL));
1378 pr_debug("Allocate %u bytes alignment gap ", size
);
1379 pr_debug("for descriptor memory.\n");
1381 if (!mac_drv_get_space(smc
, size
)) {
1382 printk("fddi: Unable to align descriptor memory.\n");
1385 return (virt
+ size
);
1386 } // mac_drv_get_desc_mem
1389 /************************
1393 * Get the physical address of a given virtual address.
1395 * smc - A pointer to the SMT context struct.
1397 * virt - A (virtual) pointer into our 'shared' memory area.
1399 * Physical address of the given virtual address.
1401 ************************/
1402 unsigned long mac_drv_virt2phys(struct s_smc
*smc
, void *virt
)
1404 return (smc
->os
.SharedMemDMA
+
1405 ((char *) virt
- (char *)smc
->os
.SharedMemAddr
));
1406 } // mac_drv_virt2phys
1409 /************************
1413 * The HWM calls this function, when the driver leads through a DMA
1414 * transfer. If the OS-specific module must prepare the system hardware
1415 * for the DMA transfer, it should do it in this function.
1417 * The hardware module calls this dma_master if it wants to send an SMT
1418 * frame. This means that the virt address passed in here is part of
1419 * the 'shared' memory area.
1421 * smc - A pointer to the SMT context struct.
1423 * virt - The virtual address of the data.
1425 * len - The length in bytes of the data.
1427 * flag - Indicates the transmit direction and the buffer type:
1428 * DMA_RD (0x01) system RAM ==> adapter buffer memory
1429 * DMA_WR (0x02) adapter buffer memory ==> system RAM
1430 * SMT_BUF (0x80) SMT buffer
1432 * >> NOTE: SMT_BUF and DMA_RD are always set for PCI. <<
1434 * Returns the pyhsical address for the DMA transfer.
1436 ************************/
1437 u_long
dma_master(struct s_smc
* smc
, void *virt
, int len
, int flag
)
1439 return (smc
->os
.SharedMemDMA
+
1440 ((char *) virt
- (char *)smc
->os
.SharedMemAddr
));
1444 /************************
1448 * The hardware module calls this routine when it has completed a DMA
1449 * transfer. If the operating system dependent module has set up the DMA
1450 * channel via dma_master() (e.g. Windows NT or AIX) it should clean up
1453 * smc - A pointer to the SMT context struct.
1455 * descr - A pointer to a TxD or RxD, respectively.
1457 * flag - Indicates the DMA transfer direction / SMT buffer:
1458 * DMA_RD (0x01) system RAM ==> adapter buffer memory
1459 * DMA_WR (0x02) adapter buffer memory ==> system RAM
1460 * SMT_BUF (0x80) SMT buffer (managed by HWM)
1464 ************************/
1465 void dma_complete(struct s_smc
*smc
, volatile union s_fp_descr
*descr
, int flag
)
1467 /* For TX buffers, there are two cases. If it is an SMT transmit
1468 * buffer, there is nothing to do since we use consistent memory
1469 * for the 'shared' memory area. The other case is for normal
1470 * transmit packets given to us by the networking stack, and in
1471 * that case we cleanup the PCI DMA mapping in mac_drv_tx_complete
1474 * For RX buffers, we have to unmap dynamic PCI DMA mappings here
1475 * because the hardware module is about to potentially look at
1476 * the contents of the buffer. If we did not call the PCI DMA
1477 * unmap first, the hardware module could read inconsistent data.
1479 if (flag
& DMA_WR
) {
1480 skfddi_priv
*bp
= &smc
->os
;
1481 volatile struct s_smt_fp_rxd
*r
= &descr
->r
;
1483 /* If SKB is NULL, we used the local buffer. */
1484 if (r
->rxd_os
.skb
&& r
->rxd_os
.dma_addr
) {
1485 int MaxFrameSize
= bp
->MaxFrameSize
;
1487 pci_unmap_single(&bp
->pdev
, r
->rxd_os
.dma_addr
,
1488 MaxFrameSize
, PCI_DMA_FROMDEVICE
);
1489 r
->rxd_os
.dma_addr
= 0;
1495 /************************
1497 * mac_drv_tx_complete
1499 * Transmit of a packet is complete. Release the tx staging buffer.
1502 * smc - A pointer to the SMT context struct.
1504 * txd - A pointer to the last TxD which is used by the frame.
1508 ************************/
1509 void mac_drv_tx_complete(struct s_smc
*smc
, volatile struct s_smt_fp_txd
*txd
)
1511 struct sk_buff
*skb
;
1513 pr_debug(KERN_INFO
"entering mac_drv_tx_complete\n");
1514 // Check if this TxD points to a skb
1516 if (!(skb
= txd
->txd_os
.skb
)) {
1517 pr_debug("TXD with no skb assigned.\n");
1520 txd
->txd_os
.skb
= NULL
;
1522 // release the DMA mapping
1523 pci_unmap_single(&smc
->os
.pdev
, txd
->txd_os
.dma_addr
,
1524 skb
->len
, PCI_DMA_TODEVICE
);
1525 txd
->txd_os
.dma_addr
= 0;
1527 smc
->os
.MacStat
.gen
.tx_packets
++; // Count transmitted packets.
1528 smc
->os
.MacStat
.gen
.tx_bytes
+=skb
->len
; // Count bytes
1531 dev_kfree_skb_irq(skb
);
1533 pr_debug(KERN_INFO
"leaving mac_drv_tx_complete\n");
1534 } // mac_drv_tx_complete
1537 /************************
1539 * dump packets to logfile
1541 ************************/
1543 void dump_data(unsigned char *Data
, int length
)
1546 unsigned char s
[255], sh
[10];
1550 printk(KERN_INFO
"---Packet start---\n");
1551 for (i
= 0, j
= 0; i
< length
/ 8; i
++, j
+= 8)
1552 printk(KERN_INFO
"%02x %02x %02x %02x %02x %02x %02x %02x\n",
1553 Data
[j
+ 0], Data
[j
+ 1], Data
[j
+ 2], Data
[j
+ 3],
1554 Data
[j
+ 4], Data
[j
+ 5], Data
[j
+ 6], Data
[j
+ 7]);
1556 for (i
= 0; i
< length
% 8; i
++) {
1557 sprintf(sh
, "%02x ", Data
[j
+ i
]);
1560 printk(KERN_INFO
"%s\n", s
);
1561 printk(KERN_INFO
"------------------\n");
1564 #define dump_data(data,len)
1565 #endif // DUMPPACKETS
1567 /************************
1569 * mac_drv_rx_complete
1571 * The hardware module calls this function if an LLC frame is received
1572 * in a receive buffer. Also the SMT, NSA, and directed beacon frames
1573 * from the network will be passed to the LLC layer by this function
1574 * if passing is enabled.
1576 * mac_drv_rx_complete forwards the frame to the LLC layer if it should
1577 * be received. It also fills the RxD ring with new receive buffers if
1578 * some can be queued.
1580 * smc - A pointer to the SMT context struct.
1582 * rxd - A pointer to the first RxD which is used by the receive frame.
1584 * frag_count - Count of RxDs used by the received frame.
1586 * len - Frame length.
1590 ************************/
1591 void mac_drv_rx_complete(struct s_smc
*smc
, volatile struct s_smt_fp_rxd
*rxd
,
1592 int frag_count
, int len
)
1594 skfddi_priv
*bp
= &smc
->os
;
1595 struct sk_buff
*skb
;
1596 unsigned char *virt
, *cp
;
1600 pr_debug(KERN_INFO
"entering mac_drv_rx_complete (len=%d)\n", len
);
1601 if (frag_count
!= 1) { // This is not allowed to happen.
1603 printk("fddi: Multi-fragment receive!\n");
1604 goto RequeueRxd
; // Re-use the given RXD(s).
1607 skb
= rxd
->rxd_os
.skb
;
1609 pr_debug(KERN_INFO
"No skb in rxd\n");
1610 smc
->os
.MacStat
.gen
.rx_errors
++;
1615 // The DMA mapping was released in dma_complete above.
1617 dump_data(skb
->data
, len
);
1620 * FDDI Frame format:
1621 * +-------+-------+-------+------------+--------+------------+
1622 * | FC[1] | DA[6] | SA[6] | RIF[0..18] | LLC[3] | Data[0..n] |
1623 * +-------+-------+-------+------------+--------+------------+
1625 * FC = Frame Control
1626 * DA = Destination Address
1627 * SA = Source Address
1628 * RIF = Routing Information Field
1629 * LLC = Logical Link Control
1632 // Remove Routing Information Field (RIF), if present.
1634 if ((virt
[1 + 6] & FDDI_RII
) == 0)
1638 // goos: RIF removal has still to be tested
1639 pr_debug(KERN_INFO
"RIF found\n");
1640 // Get RIF length from Routing Control (RC) field.
1641 cp
= virt
+ FDDI_MAC_HDR_LEN
; // Point behind MAC header.
1643 ri
= ntohs(*((__be16
*) cp
));
1644 RifLength
= ri
& FDDI_RCF_LEN_MASK
;
1645 if (len
< (int) (FDDI_MAC_HDR_LEN
+ RifLength
)) {
1646 printk("fddi: Invalid RIF.\n");
1647 goto RequeueRxd
; // Discard the frame.
1650 virt
[1 + 6] &= ~FDDI_RII
; // Clear RII bit.
1653 virt
= cp
+ RifLength
;
1654 for (n
= FDDI_MAC_HDR_LEN
; n
; n
--)
1656 // adjust sbd->data pointer
1657 skb_pull(skb
, RifLength
);
1662 // Count statistics.
1663 smc
->os
.MacStat
.gen
.rx_packets
++; // Count indicated receive
1665 smc
->os
.MacStat
.gen
.rx_bytes
+=len
; // Count bytes.
1667 // virt points to header again
1668 if (virt
[1] & 0x01) { // Check group (multicast) bit.
1670 smc
->os
.MacStat
.gen
.multicast
++;
1673 // deliver frame to system
1674 rxd
->rxd_os
.skb
= NULL
;
1676 skb
->protocol
= fddi_type_trans(skb
, bp
->dev
);
1680 HWM_RX_CHECK(smc
, RX_LOW_WATERMARK
);
1684 pr_debug(KERN_INFO
"Rx: re-queue RXD.\n");
1685 mac_drv_requeue_rxd(smc
, rxd
, frag_count
);
1686 smc
->os
.MacStat
.gen
.rx_errors
++; // Count receive packets
1689 } // mac_drv_rx_complete
1692 /************************
1694 * mac_drv_requeue_rxd
1696 * The hardware module calls this function to request the OS-specific
1697 * module to queue the receive buffer(s) represented by the pointer
1698 * to the RxD and the frag_count into the receive queue again. This
1699 * buffer was filled with an invalid frame or an SMT frame.
1701 * smc - A pointer to the SMT context struct.
1703 * rxd - A pointer to the first RxD which is used by the receive frame.
1705 * frag_count - Count of RxDs used by the received frame.
1709 ************************/
1710 void mac_drv_requeue_rxd(struct s_smc
*smc
, volatile struct s_smt_fp_rxd
*rxd
,
1713 volatile struct s_smt_fp_rxd
*next_rxd
;
1714 volatile struct s_smt_fp_rxd
*src_rxd
;
1715 struct sk_buff
*skb
;
1717 unsigned char *v_addr
;
1720 if (frag_count
!= 1) // This is not allowed to happen.
1722 printk("fddi: Multi-fragment requeue!\n");
1724 MaxFrameSize
= smc
->os
.MaxFrameSize
;
1726 for (; frag_count
> 0; frag_count
--) {
1727 next_rxd
= src_rxd
->rxd_next
;
1728 rxd
= HWM_GET_CURR_RXD(smc
);
1730 skb
= src_rxd
->rxd_os
.skb
;
1731 if (skb
== NULL
) { // this should not happen
1733 pr_debug("Requeue with no skb in rxd!\n");
1734 skb
= alloc_skb(MaxFrameSize
+ 3, GFP_ATOMIC
);
1737 rxd
->rxd_os
.skb
= skb
;
1738 skb_reserve(skb
, 3);
1739 skb_put(skb
, MaxFrameSize
);
1741 b_addr
= pci_map_single(&smc
->os
.pdev
,
1744 PCI_DMA_FROMDEVICE
);
1745 rxd
->rxd_os
.dma_addr
= b_addr
;
1747 // no skb available, use local buffer
1748 pr_debug("Queueing invalid buffer!\n");
1749 rxd
->rxd_os
.skb
= NULL
;
1750 v_addr
= smc
->os
.LocalRxBuffer
;
1751 b_addr
= smc
->os
.LocalRxBufferDMA
;
1754 // we use skb from old rxd
1755 rxd
->rxd_os
.skb
= skb
;
1757 b_addr
= pci_map_single(&smc
->os
.pdev
,
1760 PCI_DMA_FROMDEVICE
);
1761 rxd
->rxd_os
.dma_addr
= b_addr
;
1763 hwm_rx_frag(smc
, v_addr
, b_addr
, MaxFrameSize
,
1764 FIRST_FRAG
| LAST_FRAG
);
1768 } // mac_drv_requeue_rxd
1771 /************************
1775 * The hardware module calls this function at initialization time
1776 * to fill the RxD ring with receive buffers. It is also called by
1777 * mac_drv_rx_complete if rx_free is large enough to queue some new
1778 * receive buffers into the RxD ring. mac_drv_fill_rxd queues new
1779 * receive buffers as long as enough RxDs and receive buffers are
1782 * smc - A pointer to the SMT context struct.
1786 ************************/
1787 void mac_drv_fill_rxd(struct s_smc
*smc
)
1790 unsigned char *v_addr
;
1791 unsigned long b_addr
;
1792 struct sk_buff
*skb
;
1793 volatile struct s_smt_fp_rxd
*rxd
;
1795 pr_debug(KERN_INFO
"entering mac_drv_fill_rxd\n");
1797 // Walk through the list of free receive buffers, passing receive
1798 // buffers to the HWM as long as RXDs are available.
1800 MaxFrameSize
= smc
->os
.MaxFrameSize
;
1801 // Check if there is any RXD left.
1802 while (HWM_GET_RX_FREE(smc
) > 0) {
1803 pr_debug(KERN_INFO
".\n");
1805 rxd
= HWM_GET_CURR_RXD(smc
);
1806 skb
= alloc_skb(MaxFrameSize
+ 3, GFP_ATOMIC
);
1809 skb_reserve(skb
, 3);
1810 skb_put(skb
, MaxFrameSize
);
1812 b_addr
= pci_map_single(&smc
->os
.pdev
,
1815 PCI_DMA_FROMDEVICE
);
1816 rxd
->rxd_os
.dma_addr
= b_addr
;
1818 // no skb available, use local buffer
1819 // System has run out of buffer memory, but we want to
1820 // keep the receiver running in hope of better times.
1821 // Multiple descriptors may point to this local buffer,
1822 // so data in it must be considered invalid.
1823 pr_debug("Queueing invalid buffer!\n");
1824 v_addr
= smc
->os
.LocalRxBuffer
;
1825 b_addr
= smc
->os
.LocalRxBufferDMA
;
1828 rxd
->rxd_os
.skb
= skb
;
1830 // Pass receive buffer to HWM.
1831 hwm_rx_frag(smc
, v_addr
, b_addr
, MaxFrameSize
,
1832 FIRST_FRAG
| LAST_FRAG
);
1834 pr_debug(KERN_INFO
"leaving mac_drv_fill_rxd\n");
1835 } // mac_drv_fill_rxd
1838 /************************
1842 * The hardware module calls this function to release unused
1845 * smc - A pointer to the SMT context struct.
1847 * rxd - A pointer to the first RxD which is used by the receive buffer.
1849 * frag_count - Count of RxDs used by the receive buffer.
1853 ************************/
1854 void mac_drv_clear_rxd(struct s_smc
*smc
, volatile struct s_smt_fp_rxd
*rxd
,
1858 struct sk_buff
*skb
;
1860 pr_debug("entering mac_drv_clear_rxd\n");
1862 if (frag_count
!= 1) // This is not allowed to happen.
1864 printk("fddi: Multi-fragment clear!\n");
1866 for (; frag_count
> 0; frag_count
--) {
1867 skb
= rxd
->rxd_os
.skb
;
1869 skfddi_priv
*bp
= &smc
->os
;
1870 int MaxFrameSize
= bp
->MaxFrameSize
;
1872 pci_unmap_single(&bp
->pdev
, rxd
->rxd_os
.dma_addr
,
1873 MaxFrameSize
, PCI_DMA_FROMDEVICE
);
1876 rxd
->rxd_os
.skb
= NULL
;
1878 rxd
= rxd
->rxd_next
; // Next RXD.
1881 } // mac_drv_clear_rxd
1884 /************************
1888 * The hardware module calls this routine when an SMT or NSA frame of the
1889 * local SMT should be delivered to the LLC layer.
1891 * It is necessary to have this function, because there is no other way to
1892 * copy the contents of SMT MBufs into receive buffers.
1894 * mac_drv_rx_init allocates the required target memory for this frame,
1895 * and receives the frame fragment by fragment by calling mac_drv_rx_frag.
1897 * smc - A pointer to the SMT context struct.
1899 * len - The length (in bytes) of the received frame (FC, DA, SA, Data).
1901 * fc - The Frame Control field of the received frame.
1903 * look_ahead - A pointer to the lookahead data buffer (may be NULL).
1905 * la_len - The length of the lookahead data stored in the lookahead
1906 * buffer (may be zero).
1908 * Always returns zero (0).
1910 ************************/
1911 int mac_drv_rx_init(struct s_smc
*smc
, int len
, int fc
,
1912 char *look_ahead
, int la_len
)
1914 struct sk_buff
*skb
;
1916 pr_debug("entering mac_drv_rx_init(len=%d)\n", len
);
1918 // "Received" a SMT or NSA frame of the local SMT.
1920 if (len
!= la_len
|| len
< FDDI_MAC_HDR_LEN
|| !look_ahead
) {
1921 pr_debug("fddi: Discard invalid local SMT frame\n");
1922 pr_debug(" len=%d, la_len=%d, (ULONG) look_ahead=%08lXh.\n",
1923 len
, la_len
, (unsigned long) look_ahead
);
1926 skb
= alloc_skb(len
+ 3, GFP_ATOMIC
);
1928 pr_debug("fddi: Local SMT: skb memory exhausted.\n");
1931 skb_reserve(skb
, 3);
1933 skb_copy_to_linear_data(skb
, look_ahead
, len
);
1935 // deliver frame to system
1936 skb
->protocol
= fddi_type_trans(skb
, smc
->os
.dev
);
1940 } // mac_drv_rx_init
1943 /************************
1947 * This routine is called periodically by the SMT module to clean up the
1950 * Return any queued frames back to the upper protocol layers if the ring
1953 * smc - A pointer to the SMT context struct.
1957 ************************/
1958 void smt_timer_poll(struct s_smc
*smc
)
1963 /************************
1965 * ring_status_indication
1967 * This function indicates a change of the ring state.
1969 * smc - A pointer to the SMT context struct.
1971 * status - The current ring status.
1975 ************************/
1976 void ring_status_indication(struct s_smc
*smc
, u_long status
)
1978 pr_debug("ring_status_indication( ");
1979 if (status
& RS_RES15
)
1980 pr_debug("RS_RES15 ");
1981 if (status
& RS_HARDERROR
)
1982 pr_debug("RS_HARDERROR ");
1983 if (status
& RS_SOFTERROR
)
1984 pr_debug("RS_SOFTERROR ");
1985 if (status
& RS_BEACON
)
1986 pr_debug("RS_BEACON ");
1987 if (status
& RS_PATHTEST
)
1988 pr_debug("RS_PATHTEST ");
1989 if (status
& RS_SELFTEST
)
1990 pr_debug("RS_SELFTEST ");
1991 if (status
& RS_RES9
)
1992 pr_debug("RS_RES9 ");
1993 if (status
& RS_DISCONNECT
)
1994 pr_debug("RS_DISCONNECT ");
1995 if (status
& RS_RES7
)
1996 pr_debug("RS_RES7 ");
1997 if (status
& RS_DUPADDR
)
1998 pr_debug("RS_DUPADDR ");
1999 if (status
& RS_NORINGOP
)
2000 pr_debug("RS_NORINGOP ");
2001 if (status
& RS_VERSION
)
2002 pr_debug("RS_VERSION ");
2003 if (status
& RS_STUCKBYPASSS
)
2004 pr_debug("RS_STUCKBYPASSS ");
2005 if (status
& RS_EVENT
)
2006 pr_debug("RS_EVENT ");
2007 if (status
& RS_RINGOPCHANGE
)
2008 pr_debug("RS_RINGOPCHANGE ");
2009 if (status
& RS_RES0
)
2010 pr_debug("RS_RES0 ");
2012 } // ring_status_indication
2015 /************************
2019 * Gets the current time from the system.
2023 * The current time in TICKS_PER_SECOND.
2025 * TICKS_PER_SECOND has the unit 'count of timer ticks per second'. It is
2026 * defined in "targetos.h". The definition of TICKS_PER_SECOND must comply
2027 * to the time returned by smt_get_time().
2029 ************************/
2030 unsigned long smt_get_time(void)
2036 /************************
2040 * Status counter update (ring_op, fifo full).
2042 * smc - A pointer to the SMT context struct.
2044 * stat - = 0: A ring operational change occurred.
2045 * = 1: The FORMAC FIFO buffer is full / FIFO overflow.
2049 ************************/
2050 void smt_stat_counter(struct s_smc
*smc
, int stat
)
2052 // BOOLEAN RingIsUp ;
2054 pr_debug(KERN_INFO
"smt_stat_counter\n");
2057 pr_debug(KERN_INFO
"Ring operational change.\n");
2060 pr_debug(KERN_INFO
"Receive fifo overflow.\n");
2061 smc
->os
.MacStat
.gen
.rx_errors
++;
2064 pr_debug(KERN_INFO
"Unknown status (%d).\n", stat
);
2067 } // smt_stat_counter
2070 /************************
2074 * Sets CFM state in custom statistics.
2076 * smc - A pointer to the SMT context struct.
2078 * c_state - Possible values are:
2080 * EC0_OUT, EC1_IN, EC2_TRACE, EC3_LEAVE, EC4_PATH_TEST,
2081 * EC5_INSERT, EC6_CHECK, EC7_DEINSERT
2085 ************************/
2086 void cfm_state_change(struct s_smc
*smc
, int c_state
)
2114 s
= "SC10_C_WRAP_B";
2117 s
= "SC11_C_WRAP_S";
2120 pr_debug(KERN_INFO
"cfm_state_change: unknown %d\n", c_state
);
2123 pr_debug(KERN_INFO
"cfm_state_change: %s\n", s
);
2124 #endif // DRIVERDEBUG
2125 } // cfm_state_change
2128 /************************
2132 * Sets ECM state in custom statistics.
2134 * smc - A pointer to the SMT context struct.
2136 * e_state - Possible values are:
2138 * SC0_ISOLATED, SC1_WRAP_A (5), SC2_WRAP_B (6), SC4_THRU_A (12),
2139 * SC5_THRU_B (7), SC7_WRAP_S (8)
2143 ************************/
2144 void ecm_state_change(struct s_smc
*smc
, int e_state
)
2163 s
= "EC4_PATH_TEST";
2178 pr_debug(KERN_INFO
"ecm_state_change: %s\n", s
);
2179 #endif //DRIVERDEBUG
2180 } // ecm_state_change
2183 /************************
2187 * Sets RMT state in custom statistics.
2189 * smc - A pointer to the SMT context struct.
2191 * r_state - Possible values are:
2193 * RM0_ISOLATED, RM1_NON_OP, RM2_RING_OP, RM3_DETECT,
2194 * RM4_NON_OP_DUP, RM5_RING_OP_DUP, RM6_DIRECTED, RM7_TRACE
2198 ************************/
2199 void rmt_state_change(struct s_smc
*smc
, int r_state
)
2209 s
= "RM1_NON_OP - not operational";
2212 s
= "RM2_RING_OP - ring operational";
2215 s
= "RM3_DETECT - detect dupl addresses";
2217 case RM4_NON_OP_DUP
:
2218 s
= "RM4_NON_OP_DUP - dupl. addr detected";
2220 case RM5_RING_OP_DUP
:
2221 s
= "RM5_RING_OP_DUP - ring oper. with dupl. addr";
2224 s
= "RM6_DIRECTED - sending directed beacons";
2227 s
= "RM7_TRACE - trace initiated";
2233 pr_debug(KERN_INFO
"[rmt_state_change: %s]\n", s
);
2234 #endif // DRIVERDEBUG
2235 } // rmt_state_change
2238 /************************
2240 * drv_reset_indication
2242 * This function is called by the SMT when it has detected a severe
2243 * hardware problem. The driver should perform a reset on the adapter
2244 * as soon as possible, but not from within this function.
2246 * smc - A pointer to the SMT context struct.
2250 ************************/
2251 void drv_reset_indication(struct s_smc
*smc
)
2253 pr_debug(KERN_INFO
"entering drv_reset_indication\n");
2255 smc
->os
.ResetRequested
= TRUE
; // Set flag.
2257 } // drv_reset_indication
2259 static struct pci_driver skfddi_pci_driver
= {
2261 .id_table
= skfddi_pci_tbl
,
2262 .probe
= skfp_init_one
,
2263 .remove
= __devexit_p(skfp_remove_one
),
2266 static int __init
skfd_init(void)
2268 return pci_register_driver(&skfddi_pci_driver
);
2271 static void __exit
skfd_exit(void)
2273 pci_unregister_driver(&skfddi_pci_driver
);
2276 module_init(skfd_init
);
2277 module_exit(skfd_exit
);