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 functions 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/capability.h>
77 #include <linux/module.h>
78 #include <linux/kernel.h>
79 #include <linux/errno.h>
80 #include <linux/ioport.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>
87 #include <linux/gfp.h>
89 #include <asm/byteorder.h>
91 #include <asm/uaccess.h>
94 #undef ADDR // undo Linux definition
98 #include "h/smtstate.h"
101 // Define module-wide (static) routines
102 static int skfp_driver_init(struct net_device
*dev
);
103 static int skfp_open(struct net_device
*dev
);
104 static int skfp_close(struct net_device
*dev
);
105 static irqreturn_t
skfp_interrupt(int irq
, void *dev_id
);
106 static struct net_device_stats
*skfp_ctl_get_stats(struct net_device
*dev
);
107 static void skfp_ctl_set_multicast_list(struct net_device
*dev
);
108 static void skfp_ctl_set_multicast_list_wo_lock(struct net_device
*dev
);
109 static int skfp_ctl_set_mac_address(struct net_device
*dev
, void *addr
);
110 static int skfp_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
);
111 static netdev_tx_t
skfp_send_pkt(struct sk_buff
*skb
,
112 struct net_device
*dev
);
113 static void send_queued_packets(struct s_smc
*smc
);
114 static void CheckSourceAddress(unsigned char *frame
, unsigned char *hw_addr
);
115 static void ResetAdapter(struct s_smc
*smc
);
118 // Functions needed by the hardware module
119 void *mac_drv_get_space(struct s_smc
*smc
, u_int size
);
120 void *mac_drv_get_desc_mem(struct s_smc
*smc
, u_int size
);
121 unsigned long mac_drv_virt2phys(struct s_smc
*smc
, void *virt
);
122 unsigned long dma_master(struct s_smc
*smc
, void *virt
, int len
, int flag
);
123 void dma_complete(struct s_smc
*smc
, volatile union s_fp_descr
*descr
,
125 void mac_drv_tx_complete(struct s_smc
*smc
, volatile struct s_smt_fp_txd
*txd
);
126 void llc_restart_tx(struct s_smc
*smc
);
127 void mac_drv_rx_complete(struct s_smc
*smc
, volatile struct s_smt_fp_rxd
*rxd
,
128 int frag_count
, int len
);
129 void mac_drv_requeue_rxd(struct s_smc
*smc
, volatile struct s_smt_fp_rxd
*rxd
,
131 void mac_drv_fill_rxd(struct s_smc
*smc
);
132 void mac_drv_clear_rxd(struct s_smc
*smc
, volatile struct s_smt_fp_rxd
*rxd
,
134 int mac_drv_rx_init(struct s_smc
*smc
, int len
, int fc
, char *look_ahead
,
136 void dump_data(unsigned char *Data
, int length
);
138 // External functions from the hardware module
139 extern u_int
mac_drv_check_space(void);
140 extern int mac_drv_init(struct s_smc
*smc
);
141 extern void hwm_tx_frag(struct s_smc
*smc
, char far
* virt
, u_long phys
,
142 int len
, int frame_status
);
143 extern int hwm_tx_init(struct s_smc
*smc
, u_char fc
, int frag_count
,
144 int frame_len
, int frame_status
);
145 extern void fddi_isr(struct s_smc
*smc
);
146 extern void hwm_rx_frag(struct s_smc
*smc
, char far
* virt
, u_long phys
,
147 int len
, int frame_status
);
148 extern void mac_drv_rx_mode(struct s_smc
*smc
, int mode
);
149 extern void mac_drv_clear_rx_queue(struct s_smc
*smc
);
150 extern void enable_tx_irq(struct s_smc
*smc
, u_short queue
);
152 static DEFINE_PCI_DEVICE_TABLE(skfddi_pci_tbl
) = {
153 { PCI_VENDOR_ID_SK
, PCI_DEVICE_ID_SK_FP
, PCI_ANY_ID
, PCI_ANY_ID
, },
154 { } /* Terminating entry */
156 MODULE_DEVICE_TABLE(pci
, skfddi_pci_tbl
);
157 MODULE_LICENSE("GPL");
158 MODULE_AUTHOR("Mirko Lindner <mlindner@syskonnect.de>");
160 // Define module-wide (static) variables
162 static int num_boards
; /* total number of adapters configured */
164 static const struct net_device_ops skfp_netdev_ops
= {
165 .ndo_open
= skfp_open
,
166 .ndo_stop
= skfp_close
,
167 .ndo_start_xmit
= skfp_send_pkt
,
168 .ndo_get_stats
= skfp_ctl_get_stats
,
169 .ndo_change_mtu
= fddi_change_mtu
,
170 .ndo_set_rx_mode
= skfp_ctl_set_multicast_list
,
171 .ndo_set_mac_address
= skfp_ctl_set_mac_address
,
172 .ndo_do_ioctl
= skfp_ioctl
,
181 * Probes for supported FDDI PCI controllers
187 * pdev - pointer to PCI device information
189 * Functional Description:
190 * This is now called by PCI driver registration process
191 * for each board found.
194 * 0 - This device (fddi0, fddi1, etc) configured successfully
195 * -ENODEV - No devices present, or no SysKonnect FDDI PCI device
196 * present for this device name
200 * Device structures for FDDI adapters (fddi0, fddi1, etc) are
201 * initialized and the board resources are read and stored in
202 * the device structure.
204 static int skfp_init_one(struct pci_dev
*pdev
,
205 const struct pci_device_id
*ent
)
207 struct net_device
*dev
;
208 struct s_smc
*smc
; /* board pointer */
212 pr_debug("entering skfp_init_one\n");
215 printk("%s\n", boot_msg
);
217 err
= pci_enable_device(pdev
);
221 err
= pci_request_regions(pdev
, "skfddi");
225 pci_set_master(pdev
);
228 if (!(pci_resource_flags(pdev
, 0) & IORESOURCE_MEM
)) {
229 printk(KERN_ERR
"skfp: region is not an MMIO resource\n");
234 mem
= ioremap(pci_resource_start(pdev
, 0), 0x4000);
236 if (!(pci_resource_flags(pdev
, 1) & IO_RESOURCE_IO
)) {
237 printk(KERN_ERR
"skfp: region is not PIO resource\n");
242 mem
= ioport_map(pci_resource_start(pdev
, 1), FP_IO_LEN
);
245 printk(KERN_ERR
"skfp: Unable to map register, "
246 "FDDI adapter will be disabled.\n");
251 dev
= alloc_fddidev(sizeof(struct s_smc
));
253 printk(KERN_ERR
"skfp: Unable to allocate fddi device, "
254 "FDDI adapter will be disabled.\n");
259 dev
->irq
= pdev
->irq
;
260 dev
->netdev_ops
= &skfp_netdev_ops
;
262 SET_NETDEV_DEV(dev
, &pdev
->dev
);
264 /* Initialize board structure with bus-specific info */
265 smc
= netdev_priv(dev
);
267 smc
->os
.bus_type
= SK_BUS_TYPE_PCI
;
268 smc
->os
.pdev
= *pdev
;
269 smc
->os
.QueueSkb
= MAX_TX_QUEUE_LEN
;
270 smc
->os
.MaxFrameSize
= MAX_FRAME_SIZE
;
274 smc
->os
.ResetRequested
= FALSE
;
275 skb_queue_head_init(&smc
->os
.SendSkbQueue
);
277 dev
->base_addr
= (unsigned long)mem
;
279 err
= skfp_driver_init(dev
);
283 err
= register_netdev(dev
);
288 pci_set_drvdata(pdev
, dev
);
290 if ((pdev
->subsystem_device
& 0xff00) == 0x5500 ||
291 (pdev
->subsystem_device
& 0xff00) == 0x5800)
292 printk("%s: SysKonnect FDDI PCI adapter"
293 " found (SK-%04X)\n", dev
->name
,
294 pdev
->subsystem_device
);
296 printk("%s: FDDI PCI adapter found\n", dev
->name
);
300 if (smc
->os
.SharedMemAddr
)
301 pci_free_consistent(pdev
, smc
->os
.SharedMemSize
,
302 smc
->os
.SharedMemAddr
,
303 smc
->os
.SharedMemDMA
);
304 pci_free_consistent(pdev
, MAX_FRAME_SIZE
,
305 smc
->os
.LocalRxBuffer
, smc
->os
.LocalRxBufferDMA
);
315 pci_release_regions(pdev
);
317 pci_disable_device(pdev
);
322 * Called for each adapter board from pci_unregister_driver
324 static void __devexit
skfp_remove_one(struct pci_dev
*pdev
)
326 struct net_device
*p
= pci_get_drvdata(pdev
);
327 struct s_smc
*lp
= netdev_priv(p
);
329 unregister_netdev(p
);
331 if (lp
->os
.SharedMemAddr
) {
332 pci_free_consistent(&lp
->os
.pdev
,
333 lp
->os
.SharedMemSize
,
334 lp
->os
.SharedMemAddr
,
335 lp
->os
.SharedMemDMA
);
336 lp
->os
.SharedMemAddr
= NULL
;
338 if (lp
->os
.LocalRxBuffer
) {
339 pci_free_consistent(&lp
->os
.pdev
,
341 lp
->os
.LocalRxBuffer
,
342 lp
->os
.LocalRxBufferDMA
);
343 lp
->os
.LocalRxBuffer
= NULL
;
348 ioport_unmap(lp
->hw
.iop
);
350 pci_release_regions(pdev
);
353 pci_disable_device(pdev
);
354 pci_set_drvdata(pdev
, NULL
);
358 * ====================
359 * = skfp_driver_init =
360 * ====================
363 * Initializes remaining adapter board structure information
364 * and makes sure adapter is in a safe state prior to skfp_open().
370 * dev - pointer to device information
372 * Functional Description:
373 * This function allocates additional resources such as the host memory
374 * blocks needed by the adapter.
375 * The adapter is also reset. The OS must call skfp_open() to open
376 * the adapter and bring it on-line.
379 * 0 - initialization succeeded
380 * -1 - initialization failed
382 static int skfp_driver_init(struct net_device
*dev
)
384 struct s_smc
*smc
= netdev_priv(dev
);
385 skfddi_priv
*bp
= &smc
->os
;
388 pr_debug("entering skfp_driver_init\n");
390 // set the io address in private structures
391 bp
->base_addr
= dev
->base_addr
;
393 // Get the interrupt level from the PCI Configuration Table
394 smc
->hw
.irq
= dev
->irq
;
396 spin_lock_init(&bp
->DriverLock
);
398 // Allocate invalid frame
399 bp
->LocalRxBuffer
= pci_alloc_consistent(&bp
->pdev
, MAX_FRAME_SIZE
, &bp
->LocalRxBufferDMA
);
400 if (!bp
->LocalRxBuffer
) {
401 printk("could not allocate mem for ");
402 printk("LocalRxBuffer: %d byte\n", MAX_FRAME_SIZE
);
406 // Determine the required size of the 'shared' memory area.
407 bp
->SharedMemSize
= mac_drv_check_space();
408 pr_debug("Memory for HWM: %ld\n", bp
->SharedMemSize
);
409 if (bp
->SharedMemSize
> 0) {
410 bp
->SharedMemSize
+= 16; // for descriptor alignment
412 bp
->SharedMemAddr
= pci_alloc_consistent(&bp
->pdev
,
415 if (!bp
->SharedMemAddr
) {
416 printk("could not allocate mem for ");
417 printk("hardware module: %ld byte\n",
421 bp
->SharedMemHeap
= 0; // Nothing used yet.
424 bp
->SharedMemAddr
= NULL
;
425 bp
->SharedMemHeap
= 0;
426 } // SharedMemSize > 0
428 memset(bp
->SharedMemAddr
, 0, bp
->SharedMemSize
);
430 card_stop(smc
); // Reset adapter.
432 pr_debug("mac_drv_init()..\n");
433 if (mac_drv_init(smc
) != 0) {
434 pr_debug("mac_drv_init() failed\n");
437 read_address(smc
, NULL
);
438 pr_debug("HW-Addr: %pMF\n", smc
->hw
.fddi_canon_addr
.a
);
439 memcpy(dev
->dev_addr
, smc
->hw
.fddi_canon_addr
.a
, 6);
441 smt_reset_defaults(smc
, 0);
446 if (bp
->SharedMemAddr
) {
447 pci_free_consistent(&bp
->pdev
,
451 bp
->SharedMemAddr
= NULL
;
453 if (bp
->LocalRxBuffer
) {
454 pci_free_consistent(&bp
->pdev
, MAX_FRAME_SIZE
,
455 bp
->LocalRxBuffer
, bp
->LocalRxBufferDMA
);
456 bp
->LocalRxBuffer
= NULL
;
459 } // skfp_driver_init
474 * dev - pointer to device information
476 * Functional Description:
477 * This function brings the adapter to an operational state.
480 * 0 - Adapter was successfully opened
481 * -EAGAIN - Could not register IRQ
483 static int skfp_open(struct net_device
*dev
)
485 struct s_smc
*smc
= netdev_priv(dev
);
488 pr_debug("entering skfp_open\n");
489 /* Register IRQ - support shared interrupts by passing device ptr */
490 err
= request_irq(dev
->irq
, skfp_interrupt
, IRQF_SHARED
,
496 * Set current address to factory MAC address
498 * Note: We've already done this step in skfp_driver_init.
499 * However, it's possible that a user has set a node
500 * address override, then closed and reopened the
501 * adapter. Unless we reset the device address field
502 * now, we'll continue to use the existing modified
505 read_address(smc
, NULL
);
506 memcpy(dev
->dev_addr
, smc
->hw
.fddi_canon_addr
.a
, 6);
512 /* Clear local multicast address tables */
513 mac_clear_multicast(smc
);
515 /* Disable promiscuous filter settings */
516 mac_drv_rx_mode(smc
, RX_DISABLE_PROMISC
);
518 netif_start_queue(dev
);
529 * Closes the device/module.
535 * dev - pointer to device information
537 * Functional Description:
538 * This routine closes the adapter and brings it to a safe state.
539 * The interrupt service routine is deregistered with the OS.
540 * The adapter can be opened again with another call to skfp_open().
546 * No further requests for this adapter are made after this routine is
547 * called. skfp_open() can be called to reset and reinitialize the
550 static int skfp_close(struct net_device
*dev
)
552 struct s_smc
*smc
= netdev_priv(dev
);
553 skfddi_priv
*bp
= &smc
->os
;
556 smt_reset_defaults(smc
, 1);
558 mac_drv_clear_tx_queue(smc
);
559 mac_drv_clear_rx_queue(smc
);
561 netif_stop_queue(dev
);
562 /* Deregister (free) IRQ */
563 free_irq(dev
->irq
, dev
);
565 skb_queue_purge(&bp
->SendSkbQueue
);
566 bp
->QueueSkb
= MAX_TX_QUEUE_LEN
;
578 * Interrupt processing routine
584 * irq - interrupt vector
585 * dev_id - pointer to device information
587 * Functional Description:
588 * This routine calls the interrupt processing routine for this adapter. It
589 * disables and reenables adapter interrupts, as appropriate. We can support
590 * shared interrupts since the incoming dev_id pointer provides our device
591 * structure context. All the real work is done in the hardware module.
597 * The interrupt acknowledgement at the hardware level (eg. ACKing the PIC
598 * on Intel-based systems) is done by the operating system outside this
601 * System interrupts are enabled through this call.
604 * Interrupts are disabled, then reenabled at the adapter.
607 static irqreturn_t
skfp_interrupt(int irq
, void *dev_id
)
609 struct net_device
*dev
= dev_id
;
610 struct s_smc
*smc
; /* private board structure pointer */
613 smc
= netdev_priv(dev
);
616 // IRQs enabled or disabled ?
617 if (inpd(ADDR(B0_IMSK
)) == 0) {
618 // IRQs are disabled: must be shared interrupt
621 // Note: At this point, IRQs are enabled.
622 if ((inpd(ISR_A
) & smc
->hw
.is_imask
) == 0) { // IRQ?
623 // Adapter did not issue an IRQ: must be shared interrupt
626 CLI_FBI(); // Disable IRQs from our adapter.
627 spin_lock(&bp
->DriverLock
);
629 // Call interrupt handler in hardware module (HWM).
632 if (smc
->os
.ResetRequested
) {
634 smc
->os
.ResetRequested
= FALSE
;
636 spin_unlock(&bp
->DriverLock
);
637 STI_FBI(); // Enable IRQs from our adapter.
644 * ======================
645 * = skfp_ctl_get_stats =
646 * ======================
649 * Get statistics for FDDI adapter
652 * Pointer to FDDI statistics structure
655 * dev - pointer to device information
657 * Functional Description:
658 * Gets current MIB objects from adapter, then
659 * returns FDDI statistics structure as defined
662 * Note: Since the FDDI statistics structure is
663 * still new and the device structure doesn't
664 * have an FDDI-specific get statistics handler,
665 * we'll return the FDDI statistics structure as
666 * a pointer to an Ethernet statistics structure.
667 * That way, at least the first part of the statistics
668 * structure can be decoded properly.
669 * We'll have to pay attention to this routine as the
670 * device structure becomes more mature and LAN media
674 static struct net_device_stats
*skfp_ctl_get_stats(struct net_device
*dev
)
676 struct s_smc
*bp
= netdev_priv(dev
);
678 /* Fill the bp->stats structure with driver-maintained counters */
680 bp
->os
.MacStat
.port_bs_flag
[0] = 0x1234;
681 bp
->os
.MacStat
.port_bs_flag
[1] = 0x5678;
682 // goos: need to fill out fddi statistic
684 /* Get FDDI SMT MIB objects */
686 /* Fill the bp->stats structure with the SMT MIB object values */
688 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
));
689 bp
->stats
.smt_op_version_id
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_op_version_id
;
690 bp
->stats
.smt_hi_version_id
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_hi_version_id
;
691 bp
->stats
.smt_lo_version_id
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_lo_version_id
;
692 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
));
693 bp
->stats
.smt_mib_version_id
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_mib_version_id
;
694 bp
->stats
.smt_mac_cts
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_mac_ct
;
695 bp
->stats
.smt_non_master_cts
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_non_master_ct
;
696 bp
->stats
.smt_master_cts
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_master_ct
;
697 bp
->stats
.smt_available_paths
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_available_paths
;
698 bp
->stats
.smt_config_capabilities
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_config_capabilities
;
699 bp
->stats
.smt_config_policy
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_config_policy
;
700 bp
->stats
.smt_connection_policy
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_connection_policy
;
701 bp
->stats
.smt_t_notify
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_t_notify
;
702 bp
->stats
.smt_stat_rpt_policy
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_stat_rpt_policy
;
703 bp
->stats
.smt_trace_max_expiration
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_trace_max_expiration
;
704 bp
->stats
.smt_bypass_present
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_bypass_present
;
705 bp
->stats
.smt_ecm_state
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_ecm_state
;
706 bp
->stats
.smt_cf_state
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_cf_state
;
707 bp
->stats
.smt_remote_disconnect_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_remote_disconnect_flag
;
708 bp
->stats
.smt_station_status
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_station_status
;
709 bp
->stats
.smt_peer_wrap_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_peer_wrap_flag
;
710 bp
->stats
.smt_time_stamp
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_msg_time_stamp
.ls
;
711 bp
->stats
.smt_transition_time_stamp
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_transition_time_stamp
.ls
;
712 bp
->stats
.mac_frame_status_functions
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_frame_status_functions
;
713 bp
->stats
.mac_t_max_capability
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_t_max_capability
;
714 bp
->stats
.mac_tvx_capability
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_tvx_capability
;
715 bp
->stats
.mac_available_paths
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_available_paths
;
716 bp
->stats
.mac_current_path
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_current_path
;
717 memcpy(bp
->stats
.mac_upstream_nbr
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_upstream_nbr
, FDDI_K_ALEN
);
718 memcpy(bp
->stats
.mac_downstream_nbr
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_downstream_nbr
, FDDI_K_ALEN
);
719 memcpy(bp
->stats
.mac_old_upstream_nbr
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_old_upstream_nbr
, FDDI_K_ALEN
);
720 memcpy(bp
->stats
.mac_old_downstream_nbr
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_old_downstream_nbr
, FDDI_K_ALEN
);
721 bp
->stats
.mac_dup_address_test
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_dup_address_test
;
722 bp
->stats
.mac_requested_paths
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_requested_paths
;
723 bp
->stats
.mac_downstream_port_type
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_downstream_port_type
;
724 memcpy(bp
->stats
.mac_smt_address
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_smt_address
, FDDI_K_ALEN
);
725 bp
->stats
.mac_t_req
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_t_req
;
726 bp
->stats
.mac_t_neg
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_t_neg
;
727 bp
->stats
.mac_t_max
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_t_max
;
728 bp
->stats
.mac_tvx_value
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_tvx_value
;
729 bp
->stats
.mac_frame_error_threshold
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_frame_error_threshold
;
730 bp
->stats
.mac_frame_error_ratio
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_frame_error_ratio
;
731 bp
->stats
.mac_rmt_state
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_rmt_state
;
732 bp
->stats
.mac_da_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_da_flag
;
733 bp
->stats
.mac_una_da_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_unda_flag
;
734 bp
->stats
.mac_frame_error_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_frame_error_flag
;
735 bp
->stats
.mac_ma_unitdata_available
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_ma_unitdata_available
;
736 bp
->stats
.mac_hardware_present
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_hardware_present
;
737 bp
->stats
.mac_ma_unitdata_enable
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_ma_unitdata_enable
;
738 bp
->stats
.path_tvx_lower_bound
= bp
->cmd_rsp_virt
->smt_mib_get
.path_tvx_lower_bound
;
739 bp
->stats
.path_t_max_lower_bound
= bp
->cmd_rsp_virt
->smt_mib_get
.path_t_max_lower_bound
;
740 bp
->stats
.path_max_t_req
= bp
->cmd_rsp_virt
->smt_mib_get
.path_max_t_req
;
741 memcpy(bp
->stats
.path_configuration
, &bp
->cmd_rsp_virt
->smt_mib_get
.path_configuration
, sizeof(bp
->cmd_rsp_virt
->smt_mib_get
.path_configuration
));
742 bp
->stats
.port_my_type
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_my_type
[0];
743 bp
->stats
.port_my_type
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_my_type
[1];
744 bp
->stats
.port_neighbor_type
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_neighbor_type
[0];
745 bp
->stats
.port_neighbor_type
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_neighbor_type
[1];
746 bp
->stats
.port_connection_policies
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connection_policies
[0];
747 bp
->stats
.port_connection_policies
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connection_policies
[1];
748 bp
->stats
.port_mac_indicated
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_mac_indicated
[0];
749 bp
->stats
.port_mac_indicated
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_mac_indicated
[1];
750 bp
->stats
.port_current_path
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_current_path
[0];
751 bp
->stats
.port_current_path
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_current_path
[1];
752 memcpy(&bp
->stats
.port_requested_paths
[0 * 3], &bp
->cmd_rsp_virt
->smt_mib_get
.port_requested_paths
[0], 3);
753 memcpy(&bp
->stats
.port_requested_paths
[1 * 3], &bp
->cmd_rsp_virt
->smt_mib_get
.port_requested_paths
[1], 3);
754 bp
->stats
.port_mac_placement
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_mac_placement
[0];
755 bp
->stats
.port_mac_placement
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_mac_placement
[1];
756 bp
->stats
.port_available_paths
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_available_paths
[0];
757 bp
->stats
.port_available_paths
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_available_paths
[1];
758 bp
->stats
.port_pmd_class
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pmd_class
[0];
759 bp
->stats
.port_pmd_class
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pmd_class
[1];
760 bp
->stats
.port_connection_capabilities
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connection_capabilities
[0];
761 bp
->stats
.port_connection_capabilities
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connection_capabilities
[1];
762 bp
->stats
.port_bs_flag
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_bs_flag
[0];
763 bp
->stats
.port_bs_flag
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_bs_flag
[1];
764 bp
->stats
.port_ler_estimate
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_estimate
[0];
765 bp
->stats
.port_ler_estimate
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_estimate
[1];
766 bp
->stats
.port_ler_cutoff
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_cutoff
[0];
767 bp
->stats
.port_ler_cutoff
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_cutoff
[1];
768 bp
->stats
.port_ler_alarm
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_alarm
[0];
769 bp
->stats
.port_ler_alarm
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_alarm
[1];
770 bp
->stats
.port_connect_state
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connect_state
[0];
771 bp
->stats
.port_connect_state
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connect_state
[1];
772 bp
->stats
.port_pcm_state
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pcm_state
[0];
773 bp
->stats
.port_pcm_state
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pcm_state
[1];
774 bp
->stats
.port_pc_withhold
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pc_withhold
[0];
775 bp
->stats
.port_pc_withhold
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pc_withhold
[1];
776 bp
->stats
.port_ler_flag
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_flag
[0];
777 bp
->stats
.port_ler_flag
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_flag
[1];
778 bp
->stats
.port_hardware_present
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_hardware_present
[0];
779 bp
->stats
.port_hardware_present
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_hardware_present
[1];
782 /* Fill the bp->stats structure with the FDDI counter values */
784 bp
->stats
.mac_frame_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.frame_cnt
.ls
;
785 bp
->stats
.mac_copied_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.copied_cnt
.ls
;
786 bp
->stats
.mac_transmit_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.transmit_cnt
.ls
;
787 bp
->stats
.mac_error_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.error_cnt
.ls
;
788 bp
->stats
.mac_lost_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lost_cnt
.ls
;
789 bp
->stats
.port_lct_fail_cts
[0] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lct_rejects
[0].ls
;
790 bp
->stats
.port_lct_fail_cts
[1] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lct_rejects
[1].ls
;
791 bp
->stats
.port_lem_reject_cts
[0] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lem_rejects
[0].ls
;
792 bp
->stats
.port_lem_reject_cts
[1] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lem_rejects
[1].ls
;
793 bp
->stats
.port_lem_cts
[0] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.link_errors
[0].ls
;
794 bp
->stats
.port_lem_cts
[1] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.link_errors
[1].ls
;
797 return (struct net_device_stats
*)&bp
->os
.MacStat
;
802 * ==============================
803 * = skfp_ctl_set_multicast_list =
804 * ==============================
807 * Enable/Disable LLC frame promiscuous mode reception
808 * on the adapter and/or update multicast address table.
814 * dev - pointer to device information
816 * Functional Description:
817 * This function acquires the driver lock and only calls
818 * skfp_ctl_set_multicast_list_wo_lock then.
819 * This routine follows a fairly simple algorithm for setting the
820 * adapter filters and CAM:
822 * if IFF_PROMISC flag is set
823 * enable promiscuous mode
825 * disable promiscuous mode
826 * if number of multicast addresses <= max. multicast number
827 * add mc addresses to adapter table
829 * enable promiscuous mode
830 * update adapter filters
833 * Multicast addresses are presented in canonical (LSB) format.
836 * On-board adapter filters are updated.
838 static void skfp_ctl_set_multicast_list(struct net_device
*dev
)
840 struct s_smc
*smc
= netdev_priv(dev
);
841 skfddi_priv
*bp
= &smc
->os
;
844 spin_lock_irqsave(&bp
->DriverLock
, Flags
);
845 skfp_ctl_set_multicast_list_wo_lock(dev
);
846 spin_unlock_irqrestore(&bp
->DriverLock
, Flags
);
847 } // skfp_ctl_set_multicast_list
851 static void skfp_ctl_set_multicast_list_wo_lock(struct net_device
*dev
)
853 struct s_smc
*smc
= netdev_priv(dev
);
854 struct netdev_hw_addr
*ha
;
856 /* Enable promiscuous mode, if necessary */
857 if (dev
->flags
& IFF_PROMISC
) {
858 mac_drv_rx_mode(smc
, RX_ENABLE_PROMISC
);
859 pr_debug("PROMISCUOUS MODE ENABLED\n");
861 /* Else, update multicast address table */
863 mac_drv_rx_mode(smc
, RX_DISABLE_PROMISC
);
864 pr_debug("PROMISCUOUS MODE DISABLED\n");
866 // Reset all MC addresses
867 mac_clear_multicast(smc
);
868 mac_drv_rx_mode(smc
, RX_DISABLE_ALLMULTI
);
870 if (dev
->flags
& IFF_ALLMULTI
) {
871 mac_drv_rx_mode(smc
, RX_ENABLE_ALLMULTI
);
872 pr_debug("ENABLE ALL MC ADDRESSES\n");
873 } else if (!netdev_mc_empty(dev
)) {
874 if (netdev_mc_count(dev
) <= FPMAX_MULTICAST
) {
875 /* use exact filtering */
877 // point to first multicast addr
878 netdev_for_each_mc_addr(ha
, dev
) {
879 mac_add_multicast(smc
,
880 (struct fddi_addr
*)ha
->addr
,
883 pr_debug("ENABLE MC ADDRESS: %pMF\n",
887 } else { // more MC addresses than HW supports
889 mac_drv_rx_mode(smc
, RX_ENABLE_ALLMULTI
);
890 pr_debug("ENABLE ALL MC ADDRESSES\n");
892 } else { // no MC addresses
894 pr_debug("DISABLE ALL MC ADDRESSES\n");
897 /* Update adapter filters */
898 mac_update_multicast(smc
);
900 } // skfp_ctl_set_multicast_list_wo_lock
904 * ===========================
905 * = skfp_ctl_set_mac_address =
906 * ===========================
909 * set new mac address on adapter and update dev_addr field in device table.
915 * dev - pointer to device information
916 * addr - pointer to sockaddr structure containing unicast address to set
919 * The address pointed to by addr->sa_data is a valid unicast
920 * address and is presented in canonical (LSB) format.
922 static int skfp_ctl_set_mac_address(struct net_device
*dev
, void *addr
)
924 struct s_smc
*smc
= netdev_priv(dev
);
925 struct sockaddr
*p_sockaddr
= (struct sockaddr
*) addr
;
926 skfddi_priv
*bp
= &smc
->os
;
930 memcpy(dev
->dev_addr
, p_sockaddr
->sa_data
, FDDI_K_ALEN
);
931 spin_lock_irqsave(&bp
->DriverLock
, Flags
);
933 spin_unlock_irqrestore(&bp
->DriverLock
, Flags
);
935 return 0; /* always return zero */
936 } // skfp_ctl_set_mac_address
946 * Perform IOCTL call functions here. Some are privileged operations and the
947 * effective uid is checked in those cases.
955 * dev - pointer to device information
956 * rq - pointer to ioctl request structure
962 static int skfp_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
)
964 struct s_smc
*smc
= netdev_priv(dev
);
965 skfddi_priv
*lp
= &smc
->os
;
966 struct s_skfp_ioctl ioc
;
969 if (copy_from_user(&ioc
, rq
->ifr_data
, sizeof(struct s_skfp_ioctl
)))
973 case SKFP_GET_STATS
: /* Get the driver statistics */
974 ioc
.len
= sizeof(lp
->MacStat
);
975 status
= copy_to_user(ioc
.data
, skfp_ctl_get_stats(dev
), ioc
.len
)
978 case SKFP_CLR_STATS
: /* Zero out the driver statistics */
979 if (!capable(CAP_NET_ADMIN
)) {
982 memset(&lp
->MacStat
, 0, sizeof(lp
->MacStat
));
986 printk("ioctl for %s: unknown cmd: %04x\n", dev
->name
, ioc
.cmd
);
987 status
= -EOPNOTSUPP
;
996 * =====================
998 * =====================
1001 * Queues a packet for transmission and try to transmit it.
1007 * skb - pointer to sk_buff to queue for transmission
1008 * dev - pointer to device information
1010 * Functional Description:
1011 * Here we assume that an incoming skb transmit request
1012 * is contained in a single physically contiguous buffer
1013 * in which the virtual address of the start of packet
1014 * (skb->data) can be converted to a physical address
1015 * by using pci_map_single().
1017 * We have an internal queue for packets we can not send
1018 * immediately. Packets in this queue can be given to the
1019 * adapter if transmit buffers are freed.
1021 * We can't free the skb until after it's been DMA'd
1022 * out by the adapter, so we'll keep it in the driver and
1023 * return it in mac_drv_tx_complete.
1026 * 0 - driver has queued and/or sent packet
1027 * 1 - caller should requeue the sk_buff for later transmission
1030 * The entire packet is stored in one physically
1031 * contiguous buffer which is not cached and whose
1032 * 32-bit physical address can be determined.
1034 * It's vital that this routine is NOT reentered for the
1035 * same board and that the OS is not in another section of
1036 * code (eg. skfp_interrupt) for the same board on a
1042 static netdev_tx_t
skfp_send_pkt(struct sk_buff
*skb
,
1043 struct net_device
*dev
)
1045 struct s_smc
*smc
= netdev_priv(dev
);
1046 skfddi_priv
*bp
= &smc
->os
;
1048 pr_debug("skfp_send_pkt\n");
1051 * Verify that incoming transmit request is OK
1053 * Note: The packet size check is consistent with other
1054 * Linux device drivers, although the correct packet
1055 * size should be verified before calling the
1059 if (!(skb
->len
>= FDDI_K_LLC_ZLEN
&& skb
->len
<= FDDI_K_LLC_LEN
)) {
1060 bp
->MacStat
.gen
.tx_errors
++; /* bump error counter */
1061 // dequeue packets from xmt queue and send them
1062 netif_start_queue(dev
);
1064 return NETDEV_TX_OK
; /* return "success" */
1066 if (bp
->QueueSkb
== 0) { // return with tbusy set: queue full
1068 netif_stop_queue(dev
);
1069 return NETDEV_TX_BUSY
;
1072 skb_queue_tail(&bp
->SendSkbQueue
, skb
);
1073 send_queued_packets(netdev_priv(dev
));
1074 if (bp
->QueueSkb
== 0) {
1075 netif_stop_queue(dev
);
1077 return NETDEV_TX_OK
;
1083 * =======================
1084 * = send_queued_packets =
1085 * =======================
1088 * Send packets from the driver queue as long as there are some and
1089 * transmit resources are available.
1095 * smc - pointer to smc (adapter) structure
1097 * Functional Description:
1098 * Take a packet from queue if there is any. If not, then we are done.
1099 * Check if there are resources to send the packet. If not, requeue it
1101 * Set packet descriptor flags and give packet to adapter.
1102 * Check if any send resources can be freed (we do not use the
1103 * transmit complete interrupt).
1105 static void send_queued_packets(struct s_smc
*smc
)
1107 skfddi_priv
*bp
= &smc
->os
;
1108 struct sk_buff
*skb
;
1111 struct s_smt_fp_txd
*txd
; // Current TxD.
1112 dma_addr_t dma_address
;
1113 unsigned long Flags
;
1115 int frame_status
; // HWM tx frame status.
1117 pr_debug("send queued packets\n");
1119 // send first buffer from queue
1120 skb
= skb_dequeue(&bp
->SendSkbQueue
);
1123 pr_debug("queue empty\n");
1127 spin_lock_irqsave(&bp
->DriverLock
, Flags
);
1129 queue
= (fc
& FC_SYNC_BIT
) ? QUEUE_S
: QUEUE_A0
;
1131 // Check if the frame may/must be sent as a synchronous frame.
1133 if ((fc
& ~(FC_SYNC_BIT
| FC_LLC_PRIOR
)) == FC_ASYNC_LLC
) {
1134 // It's an LLC frame.
1135 if (!smc
->ess
.sync_bw_available
)
1136 fc
&= ~FC_SYNC_BIT
; // No bandwidth available.
1138 else { // Bandwidth is available.
1140 if (smc
->mib
.fddiESSSynchTxMode
) {
1141 // Send as sync. frame.
1147 frame_status
= hwm_tx_init(smc
, fc
, 1, skb
->len
, queue
);
1149 if ((frame_status
& (LOC_TX
| LAN_TX
)) == 0) {
1150 // Unable to send the frame.
1152 if ((frame_status
& RING_DOWN
) != 0) {
1154 pr_debug("Tx attempt while ring down.\n");
1155 } else if ((frame_status
& OUT_OF_TXD
) != 0) {
1156 pr_debug("%s: out of TXDs.\n", bp
->dev
->name
);
1158 pr_debug("%s: out of transmit resources",
1162 // Note: We will retry the operation as soon as
1163 // transmit resources become available.
1164 skb_queue_head(&bp
->SendSkbQueue
, skb
);
1165 spin_unlock_irqrestore(&bp
->DriverLock
, Flags
);
1166 return; // Packet has been queued.
1168 } // if (unable to send frame)
1170 bp
->QueueSkb
++; // one packet less in local queue
1172 // source address in packet ?
1173 CheckSourceAddress(skb
->data
, smc
->hw
.fddi_canon_addr
.a
);
1175 txd
= (struct s_smt_fp_txd
*) HWM_GET_CURR_TXD(smc
, queue
);
1177 dma_address
= pci_map_single(&bp
->pdev
, skb
->data
,
1178 skb
->len
, PCI_DMA_TODEVICE
);
1179 if (frame_status
& LAN_TX
) {
1180 txd
->txd_os
.skb
= skb
; // save skb
1181 txd
->txd_os
.dma_addr
= dma_address
; // save dma mapping
1183 hwm_tx_frag(smc
, skb
->data
, dma_address
, skb
->len
,
1184 frame_status
| FIRST_FRAG
| LAST_FRAG
| EN_IRQ_EOF
);
1186 if (!(frame_status
& LAN_TX
)) { // local only frame
1187 pci_unmap_single(&bp
->pdev
, dma_address
,
1188 skb
->len
, PCI_DMA_TODEVICE
);
1189 dev_kfree_skb_irq(skb
);
1191 spin_unlock_irqrestore(&bp
->DriverLock
, Flags
);
1194 return; // never reached
1196 } // send_queued_packets
1199 /************************
1201 * CheckSourceAddress
1203 * Verify if the source address is set. Insert it if necessary.
1205 ************************/
1206 static void CheckSourceAddress(unsigned char *frame
, unsigned char *hw_addr
)
1208 unsigned char SRBit
;
1210 if ((((unsigned long) frame
[1 + 6]) & ~0x01) != 0) // source routing bit
1213 if ((unsigned short) frame
[1 + 10] != 0)
1215 SRBit
= frame
[1 + 6] & 0x01;
1216 memcpy(&frame
[1 + 6], hw_addr
, 6);
1218 } // CheckSourceAddress
1221 /************************
1225 * Reset the adapter and bring it back to operational mode.
1227 * smc - A pointer to the SMT context struct.
1231 ************************/
1232 static void ResetAdapter(struct s_smc
*smc
)
1235 pr_debug("[fddi: ResetAdapter]\n");
1237 // Stop the adapter.
1239 card_stop(smc
); // Stop all activity.
1241 // Clear the transmit and receive descriptor queues.
1242 mac_drv_clear_tx_queue(smc
);
1243 mac_drv_clear_rx_queue(smc
);
1245 // Restart the adapter.
1247 smt_reset_defaults(smc
, 1); // Initialize the SMT module.
1249 init_smt(smc
, (smc
->os
.dev
)->dev_addr
); // Initialize the hardware.
1251 smt_online(smc
, 1); // Insert into the ring again.
1254 // Restore original receive mode (multicasts, promiscuous, etc.).
1255 skfp_ctl_set_multicast_list_wo_lock(smc
->os
.dev
);
1259 //--------------- functions called by hardware module ----------------
1261 /************************
1265 * The hardware driver calls this routine when the transmit complete
1266 * interrupt bits (end of frame) for the synchronous or asynchronous
1269 * NOTE The hardware driver calls this function also if no packets are queued.
1270 * The routine must be able to handle this case.
1272 * smc - A pointer to the SMT context struct.
1276 ************************/
1277 void llc_restart_tx(struct s_smc
*smc
)
1279 skfddi_priv
*bp
= &smc
->os
;
1281 pr_debug("[llc_restart_tx]\n");
1283 // Try to send queued packets
1284 spin_unlock(&bp
->DriverLock
);
1285 send_queued_packets(smc
);
1286 spin_lock(&bp
->DriverLock
);
1287 netif_start_queue(bp
->dev
);// system may send again if it was blocked
1292 /************************
1296 * The hardware module calls this function to allocate the memory
1297 * for the SMT MBufs if the define MB_OUTSIDE_SMC is specified.
1299 * smc - A pointer to the SMT context struct.
1301 * size - Size of memory in bytes to allocate.
1303 * != 0 A pointer to the virtual address of the allocated memory.
1304 * == 0 Allocation error.
1306 ************************/
1307 void *mac_drv_get_space(struct s_smc
*smc
, unsigned int size
)
1311 pr_debug("mac_drv_get_space (%d bytes), ", size
);
1312 virt
= (void *) (smc
->os
.SharedMemAddr
+ smc
->os
.SharedMemHeap
);
1314 if ((smc
->os
.SharedMemHeap
+ size
) > smc
->os
.SharedMemSize
) {
1315 printk("Unexpected SMT memory size requested: %d\n", size
);
1318 smc
->os
.SharedMemHeap
+= size
; // Move heap pointer.
1320 pr_debug("mac_drv_get_space end\n");
1321 pr_debug("virt addr: %lx\n", (ulong
) virt
);
1322 pr_debug("bus addr: %lx\n", (ulong
)
1323 (smc
->os
.SharedMemDMA
+
1324 ((char *) virt
- (char *)smc
->os
.SharedMemAddr
)));
1326 } // mac_drv_get_space
1329 /************************
1331 * mac_drv_get_desc_mem
1333 * This function is called by the hardware dependent module.
1334 * It allocates the memory for the RxD and TxD descriptors.
1336 * This memory must be non-cached, non-movable and non-swappable.
1337 * This memory should start at a physical page boundary.
1339 * smc - A pointer to the SMT context struct.
1341 * size - Size of memory in bytes to allocate.
1343 * != 0 A pointer to the virtual address of the allocated memory.
1344 * == 0 Allocation error.
1346 ************************/
1347 void *mac_drv_get_desc_mem(struct s_smc
*smc
, unsigned int size
)
1352 pr_debug("mac_drv_get_desc_mem\n");
1354 // Descriptor memory must be aligned on 16-byte boundary.
1356 virt
= mac_drv_get_space(smc
, size
);
1358 size
= (u_int
) (16 - (((unsigned long) virt
) & 15UL));
1361 pr_debug("Allocate %u bytes alignment gap ", size
);
1362 pr_debug("for descriptor memory.\n");
1364 if (!mac_drv_get_space(smc
, size
)) {
1365 printk("fddi: Unable to align descriptor memory.\n");
1369 } // mac_drv_get_desc_mem
1372 /************************
1376 * Get the physical address of a given virtual address.
1378 * smc - A pointer to the SMT context struct.
1380 * virt - A (virtual) pointer into our 'shared' memory area.
1382 * Physical address of the given virtual address.
1384 ************************/
1385 unsigned long mac_drv_virt2phys(struct s_smc
*smc
, void *virt
)
1387 return smc
->os
.SharedMemDMA
+
1388 ((char *) virt
- (char *)smc
->os
.SharedMemAddr
);
1389 } // mac_drv_virt2phys
1392 /************************
1396 * The HWM calls this function, when the driver leads through a DMA
1397 * transfer. If the OS-specific module must prepare the system hardware
1398 * for the DMA transfer, it should do it in this function.
1400 * The hardware module calls this dma_master if it wants to send an SMT
1401 * frame. This means that the virt address passed in here is part of
1402 * the 'shared' memory area.
1404 * smc - A pointer to the SMT context struct.
1406 * virt - The virtual address of the data.
1408 * len - The length in bytes of the data.
1410 * flag - Indicates the transmit direction and the buffer type:
1411 * DMA_RD (0x01) system RAM ==> adapter buffer memory
1412 * DMA_WR (0x02) adapter buffer memory ==> system RAM
1413 * SMT_BUF (0x80) SMT buffer
1415 * >> NOTE: SMT_BUF and DMA_RD are always set for PCI. <<
1417 * Returns the pyhsical address for the DMA transfer.
1419 ************************/
1420 u_long
dma_master(struct s_smc
* smc
, void *virt
, int len
, int flag
)
1422 return smc
->os
.SharedMemDMA
+
1423 ((char *) virt
- (char *)smc
->os
.SharedMemAddr
);
1427 /************************
1431 * The hardware module calls this routine when it has completed a DMA
1432 * transfer. If the operating system dependent module has set up the DMA
1433 * channel via dma_master() (e.g. Windows NT or AIX) it should clean up
1436 * smc - A pointer to the SMT context struct.
1438 * descr - A pointer to a TxD or RxD, respectively.
1440 * flag - Indicates the DMA transfer direction / SMT buffer:
1441 * DMA_RD (0x01) system RAM ==> adapter buffer memory
1442 * DMA_WR (0x02) adapter buffer memory ==> system RAM
1443 * SMT_BUF (0x80) SMT buffer (managed by HWM)
1447 ************************/
1448 void dma_complete(struct s_smc
*smc
, volatile union s_fp_descr
*descr
, int flag
)
1450 /* For TX buffers, there are two cases. If it is an SMT transmit
1451 * buffer, there is nothing to do since we use consistent memory
1452 * for the 'shared' memory area. The other case is for normal
1453 * transmit packets given to us by the networking stack, and in
1454 * that case we cleanup the PCI DMA mapping in mac_drv_tx_complete
1457 * For RX buffers, we have to unmap dynamic PCI DMA mappings here
1458 * because the hardware module is about to potentially look at
1459 * the contents of the buffer. If we did not call the PCI DMA
1460 * unmap first, the hardware module could read inconsistent data.
1462 if (flag
& DMA_WR
) {
1463 skfddi_priv
*bp
= &smc
->os
;
1464 volatile struct s_smt_fp_rxd
*r
= &descr
->r
;
1466 /* If SKB is NULL, we used the local buffer. */
1467 if (r
->rxd_os
.skb
&& r
->rxd_os
.dma_addr
) {
1468 int MaxFrameSize
= bp
->MaxFrameSize
;
1470 pci_unmap_single(&bp
->pdev
, r
->rxd_os
.dma_addr
,
1471 MaxFrameSize
, PCI_DMA_FROMDEVICE
);
1472 r
->rxd_os
.dma_addr
= 0;
1478 /************************
1480 * mac_drv_tx_complete
1482 * Transmit of a packet is complete. Release the tx staging buffer.
1485 * smc - A pointer to the SMT context struct.
1487 * txd - A pointer to the last TxD which is used by the frame.
1491 ************************/
1492 void mac_drv_tx_complete(struct s_smc
*smc
, volatile struct s_smt_fp_txd
*txd
)
1494 struct sk_buff
*skb
;
1496 pr_debug("entering mac_drv_tx_complete\n");
1497 // Check if this TxD points to a skb
1499 if (!(skb
= txd
->txd_os
.skb
)) {
1500 pr_debug("TXD with no skb assigned.\n");
1503 txd
->txd_os
.skb
= NULL
;
1505 // release the DMA mapping
1506 pci_unmap_single(&smc
->os
.pdev
, txd
->txd_os
.dma_addr
,
1507 skb
->len
, PCI_DMA_TODEVICE
);
1508 txd
->txd_os
.dma_addr
= 0;
1510 smc
->os
.MacStat
.gen
.tx_packets
++; // Count transmitted packets.
1511 smc
->os
.MacStat
.gen
.tx_bytes
+=skb
->len
; // Count bytes
1514 dev_kfree_skb_irq(skb
);
1516 pr_debug("leaving mac_drv_tx_complete\n");
1517 } // mac_drv_tx_complete
1520 /************************
1522 * dump packets to logfile
1524 ************************/
1526 void dump_data(unsigned char *Data
, int length
)
1529 unsigned char s
[255], sh
[10];
1533 printk(KERN_INFO
"---Packet start---\n");
1534 for (i
= 0, j
= 0; i
< length
/ 8; i
++, j
+= 8)
1535 printk(KERN_INFO
"%02x %02x %02x %02x %02x %02x %02x %02x\n",
1536 Data
[j
+ 0], Data
[j
+ 1], Data
[j
+ 2], Data
[j
+ 3],
1537 Data
[j
+ 4], Data
[j
+ 5], Data
[j
+ 6], Data
[j
+ 7]);
1539 for (i
= 0; i
< length
% 8; i
++) {
1540 sprintf(sh
, "%02x ", Data
[j
+ i
]);
1543 printk(KERN_INFO
"%s\n", s
);
1544 printk(KERN_INFO
"------------------\n");
1547 #define dump_data(data,len)
1548 #endif // DUMPPACKETS
1550 /************************
1552 * mac_drv_rx_complete
1554 * The hardware module calls this function if an LLC frame is received
1555 * in a receive buffer. Also the SMT, NSA, and directed beacon frames
1556 * from the network will be passed to the LLC layer by this function
1557 * if passing is enabled.
1559 * mac_drv_rx_complete forwards the frame to the LLC layer if it should
1560 * be received. It also fills the RxD ring with new receive buffers if
1561 * some can be queued.
1563 * smc - A pointer to the SMT context struct.
1565 * rxd - A pointer to the first RxD which is used by the receive frame.
1567 * frag_count - Count of RxDs used by the received frame.
1569 * len - Frame length.
1573 ************************/
1574 void mac_drv_rx_complete(struct s_smc
*smc
, volatile struct s_smt_fp_rxd
*rxd
,
1575 int frag_count
, int len
)
1577 skfddi_priv
*bp
= &smc
->os
;
1578 struct sk_buff
*skb
;
1579 unsigned char *virt
, *cp
;
1583 pr_debug("entering mac_drv_rx_complete (len=%d)\n", len
);
1584 if (frag_count
!= 1) { // This is not allowed to happen.
1586 printk("fddi: Multi-fragment receive!\n");
1587 goto RequeueRxd
; // Re-use the given RXD(s).
1590 skb
= rxd
->rxd_os
.skb
;
1592 pr_debug("No skb in rxd\n");
1593 smc
->os
.MacStat
.gen
.rx_errors
++;
1598 // The DMA mapping was released in dma_complete above.
1600 dump_data(skb
->data
, len
);
1603 * FDDI Frame format:
1604 * +-------+-------+-------+------------+--------+------------+
1605 * | FC[1] | DA[6] | SA[6] | RIF[0..18] | LLC[3] | Data[0..n] |
1606 * +-------+-------+-------+------------+--------+------------+
1608 * FC = Frame Control
1609 * DA = Destination Address
1610 * SA = Source Address
1611 * RIF = Routing Information Field
1612 * LLC = Logical Link Control
1615 // Remove Routing Information Field (RIF), if present.
1617 if ((virt
[1 + 6] & FDDI_RII
) == 0)
1621 // goos: RIF removal has still to be tested
1622 pr_debug("RIF found\n");
1623 // Get RIF length from Routing Control (RC) field.
1624 cp
= virt
+ FDDI_MAC_HDR_LEN
; // Point behind MAC header.
1626 ri
= ntohs(*((__be16
*) cp
));
1627 RifLength
= ri
& FDDI_RCF_LEN_MASK
;
1628 if (len
< (int) (FDDI_MAC_HDR_LEN
+ RifLength
)) {
1629 printk("fddi: Invalid RIF.\n");
1630 goto RequeueRxd
; // Discard the frame.
1633 virt
[1 + 6] &= ~FDDI_RII
; // Clear RII bit.
1636 virt
= cp
+ RifLength
;
1637 for (n
= FDDI_MAC_HDR_LEN
; n
; n
--)
1639 // adjust sbd->data pointer
1640 skb_pull(skb
, RifLength
);
1645 // Count statistics.
1646 smc
->os
.MacStat
.gen
.rx_packets
++; // Count indicated receive
1648 smc
->os
.MacStat
.gen
.rx_bytes
+=len
; // Count bytes.
1650 // virt points to header again
1651 if (virt
[1] & 0x01) { // Check group (multicast) bit.
1653 smc
->os
.MacStat
.gen
.multicast
++;
1656 // deliver frame to system
1657 rxd
->rxd_os
.skb
= NULL
;
1659 skb
->protocol
= fddi_type_trans(skb
, bp
->dev
);
1663 HWM_RX_CHECK(smc
, RX_LOW_WATERMARK
);
1667 pr_debug("Rx: re-queue RXD.\n");
1668 mac_drv_requeue_rxd(smc
, rxd
, frag_count
);
1669 smc
->os
.MacStat
.gen
.rx_errors
++; // Count receive packets
1672 } // mac_drv_rx_complete
1675 /************************
1677 * mac_drv_requeue_rxd
1679 * The hardware module calls this function to request the OS-specific
1680 * module to queue the receive buffer(s) represented by the pointer
1681 * to the RxD and the frag_count into the receive queue again. This
1682 * buffer was filled with an invalid frame or an SMT frame.
1684 * smc - A pointer to the SMT context struct.
1686 * rxd - A pointer to the first RxD which is used by the receive frame.
1688 * frag_count - Count of RxDs used by the received frame.
1692 ************************/
1693 void mac_drv_requeue_rxd(struct s_smc
*smc
, volatile struct s_smt_fp_rxd
*rxd
,
1696 volatile struct s_smt_fp_rxd
*next_rxd
;
1697 volatile struct s_smt_fp_rxd
*src_rxd
;
1698 struct sk_buff
*skb
;
1700 unsigned char *v_addr
;
1703 if (frag_count
!= 1) // This is not allowed to happen.
1705 printk("fddi: Multi-fragment requeue!\n");
1707 MaxFrameSize
= smc
->os
.MaxFrameSize
;
1709 for (; frag_count
> 0; frag_count
--) {
1710 next_rxd
= src_rxd
->rxd_next
;
1711 rxd
= HWM_GET_CURR_RXD(smc
);
1713 skb
= src_rxd
->rxd_os
.skb
;
1714 if (skb
== NULL
) { // this should not happen
1716 pr_debug("Requeue with no skb in rxd!\n");
1717 skb
= alloc_skb(MaxFrameSize
+ 3, GFP_ATOMIC
);
1720 rxd
->rxd_os
.skb
= skb
;
1721 skb_reserve(skb
, 3);
1722 skb_put(skb
, MaxFrameSize
);
1724 b_addr
= pci_map_single(&smc
->os
.pdev
,
1727 PCI_DMA_FROMDEVICE
);
1728 rxd
->rxd_os
.dma_addr
= b_addr
;
1730 // no skb available, use local buffer
1731 pr_debug("Queueing invalid buffer!\n");
1732 rxd
->rxd_os
.skb
= NULL
;
1733 v_addr
= smc
->os
.LocalRxBuffer
;
1734 b_addr
= smc
->os
.LocalRxBufferDMA
;
1737 // we use skb from old rxd
1738 rxd
->rxd_os
.skb
= skb
;
1740 b_addr
= pci_map_single(&smc
->os
.pdev
,
1743 PCI_DMA_FROMDEVICE
);
1744 rxd
->rxd_os
.dma_addr
= b_addr
;
1746 hwm_rx_frag(smc
, v_addr
, b_addr
, MaxFrameSize
,
1747 FIRST_FRAG
| LAST_FRAG
);
1751 } // mac_drv_requeue_rxd
1754 /************************
1758 * The hardware module calls this function at initialization time
1759 * to fill the RxD ring with receive buffers. It is also called by
1760 * mac_drv_rx_complete if rx_free is large enough to queue some new
1761 * receive buffers into the RxD ring. mac_drv_fill_rxd queues new
1762 * receive buffers as long as enough RxDs and receive buffers are
1765 * smc - A pointer to the SMT context struct.
1769 ************************/
1770 void mac_drv_fill_rxd(struct s_smc
*smc
)
1773 unsigned char *v_addr
;
1774 unsigned long b_addr
;
1775 struct sk_buff
*skb
;
1776 volatile struct s_smt_fp_rxd
*rxd
;
1778 pr_debug("entering mac_drv_fill_rxd\n");
1780 // Walk through the list of free receive buffers, passing receive
1781 // buffers to the HWM as long as RXDs are available.
1783 MaxFrameSize
= smc
->os
.MaxFrameSize
;
1784 // Check if there is any RXD left.
1785 while (HWM_GET_RX_FREE(smc
) > 0) {
1788 rxd
= HWM_GET_CURR_RXD(smc
);
1789 skb
= alloc_skb(MaxFrameSize
+ 3, GFP_ATOMIC
);
1792 skb_reserve(skb
, 3);
1793 skb_put(skb
, MaxFrameSize
);
1795 b_addr
= pci_map_single(&smc
->os
.pdev
,
1798 PCI_DMA_FROMDEVICE
);
1799 rxd
->rxd_os
.dma_addr
= b_addr
;
1801 // no skb available, use local buffer
1802 // System has run out of buffer memory, but we want to
1803 // keep the receiver running in hope of better times.
1804 // Multiple descriptors may point to this local buffer,
1805 // so data in it must be considered invalid.
1806 pr_debug("Queueing invalid buffer!\n");
1807 v_addr
= smc
->os
.LocalRxBuffer
;
1808 b_addr
= smc
->os
.LocalRxBufferDMA
;
1811 rxd
->rxd_os
.skb
= skb
;
1813 // Pass receive buffer to HWM.
1814 hwm_rx_frag(smc
, v_addr
, b_addr
, MaxFrameSize
,
1815 FIRST_FRAG
| LAST_FRAG
);
1817 pr_debug("leaving mac_drv_fill_rxd\n");
1818 } // mac_drv_fill_rxd
1821 /************************
1825 * The hardware module calls this function to release unused
1828 * smc - A pointer to the SMT context struct.
1830 * rxd - A pointer to the first RxD which is used by the receive buffer.
1832 * frag_count - Count of RxDs used by the receive buffer.
1836 ************************/
1837 void mac_drv_clear_rxd(struct s_smc
*smc
, volatile struct s_smt_fp_rxd
*rxd
,
1841 struct sk_buff
*skb
;
1843 pr_debug("entering mac_drv_clear_rxd\n");
1845 if (frag_count
!= 1) // This is not allowed to happen.
1847 printk("fddi: Multi-fragment clear!\n");
1849 for (; frag_count
> 0; frag_count
--) {
1850 skb
= rxd
->rxd_os
.skb
;
1852 skfddi_priv
*bp
= &smc
->os
;
1853 int MaxFrameSize
= bp
->MaxFrameSize
;
1855 pci_unmap_single(&bp
->pdev
, rxd
->rxd_os
.dma_addr
,
1856 MaxFrameSize
, PCI_DMA_FROMDEVICE
);
1859 rxd
->rxd_os
.skb
= NULL
;
1861 rxd
= rxd
->rxd_next
; // Next RXD.
1864 } // mac_drv_clear_rxd
1867 /************************
1871 * The hardware module calls this routine when an SMT or NSA frame of the
1872 * local SMT should be delivered to the LLC layer.
1874 * It is necessary to have this function, because there is no other way to
1875 * copy the contents of SMT MBufs into receive buffers.
1877 * mac_drv_rx_init allocates the required target memory for this frame,
1878 * and receives the frame fragment by fragment by calling mac_drv_rx_frag.
1880 * smc - A pointer to the SMT context struct.
1882 * len - The length (in bytes) of the received frame (FC, DA, SA, Data).
1884 * fc - The Frame Control field of the received frame.
1886 * look_ahead - A pointer to the lookahead data buffer (may be NULL).
1888 * la_len - The length of the lookahead data stored in the lookahead
1889 * buffer (may be zero).
1891 * Always returns zero (0).
1893 ************************/
1894 int mac_drv_rx_init(struct s_smc
*smc
, int len
, int fc
,
1895 char *look_ahead
, int la_len
)
1897 struct sk_buff
*skb
;
1899 pr_debug("entering mac_drv_rx_init(len=%d)\n", len
);
1901 // "Received" a SMT or NSA frame of the local SMT.
1903 if (len
!= la_len
|| len
< FDDI_MAC_HDR_LEN
|| !look_ahead
) {
1904 pr_debug("fddi: Discard invalid local SMT frame\n");
1905 pr_debug(" len=%d, la_len=%d, (ULONG) look_ahead=%08lXh.\n",
1906 len
, la_len
, (unsigned long) look_ahead
);
1909 skb
= alloc_skb(len
+ 3, GFP_ATOMIC
);
1911 pr_debug("fddi: Local SMT: skb memory exhausted.\n");
1914 skb_reserve(skb
, 3);
1916 skb_copy_to_linear_data(skb
, look_ahead
, len
);
1918 // deliver frame to system
1919 skb
->protocol
= fddi_type_trans(skb
, smc
->os
.dev
);
1923 } // mac_drv_rx_init
1926 /************************
1930 * This routine is called periodically by the SMT module to clean up the
1933 * Return any queued frames back to the upper protocol layers if the ring
1936 * smc - A pointer to the SMT context struct.
1940 ************************/
1941 void smt_timer_poll(struct s_smc
*smc
)
1946 /************************
1948 * ring_status_indication
1950 * This function indicates a change of the ring state.
1952 * smc - A pointer to the SMT context struct.
1954 * status - The current ring status.
1958 ************************/
1959 void ring_status_indication(struct s_smc
*smc
, u_long status
)
1961 pr_debug("ring_status_indication( ");
1962 if (status
& RS_RES15
)
1963 pr_debug("RS_RES15 ");
1964 if (status
& RS_HARDERROR
)
1965 pr_debug("RS_HARDERROR ");
1966 if (status
& RS_SOFTERROR
)
1967 pr_debug("RS_SOFTERROR ");
1968 if (status
& RS_BEACON
)
1969 pr_debug("RS_BEACON ");
1970 if (status
& RS_PATHTEST
)
1971 pr_debug("RS_PATHTEST ");
1972 if (status
& RS_SELFTEST
)
1973 pr_debug("RS_SELFTEST ");
1974 if (status
& RS_RES9
)
1975 pr_debug("RS_RES9 ");
1976 if (status
& RS_DISCONNECT
)
1977 pr_debug("RS_DISCONNECT ");
1978 if (status
& RS_RES7
)
1979 pr_debug("RS_RES7 ");
1980 if (status
& RS_DUPADDR
)
1981 pr_debug("RS_DUPADDR ");
1982 if (status
& RS_NORINGOP
)
1983 pr_debug("RS_NORINGOP ");
1984 if (status
& RS_VERSION
)
1985 pr_debug("RS_VERSION ");
1986 if (status
& RS_STUCKBYPASSS
)
1987 pr_debug("RS_STUCKBYPASSS ");
1988 if (status
& RS_EVENT
)
1989 pr_debug("RS_EVENT ");
1990 if (status
& RS_RINGOPCHANGE
)
1991 pr_debug("RS_RINGOPCHANGE ");
1992 if (status
& RS_RES0
)
1993 pr_debug("RS_RES0 ");
1995 } // ring_status_indication
1998 /************************
2002 * Gets the current time from the system.
2006 * The current time in TICKS_PER_SECOND.
2008 * TICKS_PER_SECOND has the unit 'count of timer ticks per second'. It is
2009 * defined in "targetos.h". The definition of TICKS_PER_SECOND must comply
2010 * to the time returned by smt_get_time().
2012 ************************/
2013 unsigned long smt_get_time(void)
2019 /************************
2023 * Status counter update (ring_op, fifo full).
2025 * smc - A pointer to the SMT context struct.
2027 * stat - = 0: A ring operational change occurred.
2028 * = 1: The FORMAC FIFO buffer is full / FIFO overflow.
2032 ************************/
2033 void smt_stat_counter(struct s_smc
*smc
, int stat
)
2035 // BOOLEAN RingIsUp ;
2037 pr_debug("smt_stat_counter\n");
2040 pr_debug("Ring operational change.\n");
2043 pr_debug("Receive fifo overflow.\n");
2044 smc
->os
.MacStat
.gen
.rx_errors
++;
2047 pr_debug("Unknown status (%d).\n", stat
);
2050 } // smt_stat_counter
2053 /************************
2057 * Sets CFM state in custom statistics.
2059 * smc - A pointer to the SMT context struct.
2061 * c_state - Possible values are:
2063 * EC0_OUT, EC1_IN, EC2_TRACE, EC3_LEAVE, EC4_PATH_TEST,
2064 * EC5_INSERT, EC6_CHECK, EC7_DEINSERT
2068 ************************/
2069 void cfm_state_change(struct s_smc
*smc
, int c_state
)
2097 s
= "SC10_C_WRAP_B";
2100 s
= "SC11_C_WRAP_S";
2103 pr_debug("cfm_state_change: unknown %d\n", c_state
);
2106 pr_debug("cfm_state_change: %s\n", s
);
2107 #endif // DRIVERDEBUG
2108 } // cfm_state_change
2111 /************************
2115 * Sets ECM state in custom statistics.
2117 * smc - A pointer to the SMT context struct.
2119 * e_state - Possible values are:
2121 * SC0_ISOLATED, SC1_WRAP_A (5), SC2_WRAP_B (6), SC4_THRU_A (12),
2122 * SC5_THRU_B (7), SC7_WRAP_S (8)
2126 ************************/
2127 void ecm_state_change(struct s_smc
*smc
, int e_state
)
2146 s
= "EC4_PATH_TEST";
2161 pr_debug("ecm_state_change: %s\n", s
);
2162 #endif //DRIVERDEBUG
2163 } // ecm_state_change
2166 /************************
2170 * Sets RMT state in custom statistics.
2172 * smc - A pointer to the SMT context struct.
2174 * r_state - Possible values are:
2176 * RM0_ISOLATED, RM1_NON_OP, RM2_RING_OP, RM3_DETECT,
2177 * RM4_NON_OP_DUP, RM5_RING_OP_DUP, RM6_DIRECTED, RM7_TRACE
2181 ************************/
2182 void rmt_state_change(struct s_smc
*smc
, int r_state
)
2192 s
= "RM1_NON_OP - not operational";
2195 s
= "RM2_RING_OP - ring operational";
2198 s
= "RM3_DETECT - detect dupl addresses";
2200 case RM4_NON_OP_DUP
:
2201 s
= "RM4_NON_OP_DUP - dupl. addr detected";
2203 case RM5_RING_OP_DUP
:
2204 s
= "RM5_RING_OP_DUP - ring oper. with dupl. addr";
2207 s
= "RM6_DIRECTED - sending directed beacons";
2210 s
= "RM7_TRACE - trace initiated";
2216 pr_debug("[rmt_state_change: %s]\n", s
);
2217 #endif // DRIVERDEBUG
2218 } // rmt_state_change
2221 /************************
2223 * drv_reset_indication
2225 * This function is called by the SMT when it has detected a severe
2226 * hardware problem. The driver should perform a reset on the adapter
2227 * as soon as possible, but not from within this function.
2229 * smc - A pointer to the SMT context struct.
2233 ************************/
2234 void drv_reset_indication(struct s_smc
*smc
)
2236 pr_debug("entering drv_reset_indication\n");
2238 smc
->os
.ResetRequested
= TRUE
; // Set flag.
2240 } // drv_reset_indication
2242 static struct pci_driver skfddi_pci_driver
= {
2244 .id_table
= skfddi_pci_tbl
,
2245 .probe
= skfp_init_one
,
2246 .remove
= __devexit_p(skfp_remove_one
),
2249 static int __init
skfd_init(void)
2251 return pci_register_driver(&skfddi_pci_driver
);
2254 static void __exit
skfd_exit(void)
2256 pci_unregister_driver(&skfddi_pci_driver
);
2259 module_init(skfd_init
);
2260 module_exit(skfd_exit
);