1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Copyright Information:
7 * Copyright SysKonnect 1998,1999.
9 * The information in this file is provided "AS IS" without warranty.
12 * A Linux device driver supporting the SysKonnect FDDI PCI controller
16 * CG Christoph Goos (cgoos@syskonnect.de)
21 * Address all question to:
24 * The technical manual for the adapters is available from SysKonnect's
25 * web pages: www.syskonnect.com
26 * Goto "Support" and search Knowledge Base for "manual".
28 * Driver Architecture:
29 * The driver architecture is based on the DEC FDDI driver by
30 * Lawrence V. Stefani and several ethernet drivers.
31 * I also used an existing Windows NT miniport driver.
32 * All hardware dependent functions are handled by the SysKonnect
34 * The only headerfiles that are directly related to this source
35 * are skfddi.c, h/types.h, h/osdef1st.h, h/targetos.h.
36 * The others belong to the SysKonnect FDDI Hardware Module and
37 * should better not be changed.
39 * Modification History:
40 * Date Name Description
41 * 02-Mar-98 CG Created.
43 * 10-Mar-99 CG Support for 2.2.x added.
44 * 25-Mar-99 CG Corrected IRQ routing for SMP (APIC)
45 * 26-Oct-99 CG Fixed compilation error on 2.2.13
46 * 12-Nov-99 CG Source code release
47 * 22-Nov-99 CG Included in kernel source.
48 * 07-May-00 DM 64 bit fixes, new dma interface
49 * 31-Jul-03 DB Audit copy_*_user in skfp_ioctl
50 * Daniele Bellucci <bellucda@tiscali.it>
51 * 03-Dec-03 SH Convert to PCI device model
53 * Compilation options (-Dxxx):
54 * DRIVERDEBUG print lots of messages to log file
55 * DUMPPACKETS print received/transmitted packets to logfile
57 * Tested cpu architectures:
62 /* Version information string - should be updated prior to */
63 /* each new release!!! */
64 #define VERSION "2.07"
66 static const char * const boot_msg
=
67 "SysKonnect FDDI PCI Adapter driver v" VERSION
" for\n"
68 " SK-55xx/SK-58xx adapters (SK-NET FDDI-FP/UP/LP)";
72 #include <linux/capability.h>
73 #include <linux/compat.h>
74 #include <linux/module.h>
75 #include <linux/kernel.h>
76 #include <linux/errno.h>
77 #include <linux/ioport.h>
78 #include <linux/interrupt.h>
79 #include <linux/pci.h>
80 #include <linux/netdevice.h>
81 #include <linux/etherdevice.h>
82 #include <linux/fddidevice.h>
83 #include <linux/skbuff.h>
84 #include <linux/bitops.h>
85 #include <linux/gfp.h>
87 #include <asm/byteorder.h>
89 #include <linux/uaccess.h>
92 #undef ADDR // undo Linux definition
96 #include "h/smtstate.h"
99 // Define module-wide (static) routines
100 static int skfp_driver_init(struct net_device
*dev
);
101 static int skfp_open(struct net_device
*dev
);
102 static int skfp_close(struct net_device
*dev
);
103 static irqreturn_t
skfp_interrupt(int irq
, void *dev_id
);
104 static struct net_device_stats
*skfp_ctl_get_stats(struct net_device
*dev
);
105 static void skfp_ctl_set_multicast_list(struct net_device
*dev
);
106 static void skfp_ctl_set_multicast_list_wo_lock(struct net_device
*dev
);
107 static int skfp_ctl_set_mac_address(struct net_device
*dev
, void *addr
);
108 static int skfp_siocdevprivate(struct net_device
*dev
, struct ifreq
*rq
,
109 void __user
*data
, int cmd
);
110 static netdev_tx_t
skfp_send_pkt(struct sk_buff
*skb
,
111 struct net_device
*dev
);
112 static void send_queued_packets(struct s_smc
*smc
);
113 static void CheckSourceAddress(unsigned char *frame
, unsigned char *hw_addr
);
114 static void ResetAdapter(struct s_smc
*smc
);
117 // Functions needed by the hardware module
118 void *mac_drv_get_space(struct s_smc
*smc
, u_int size
);
119 void *mac_drv_get_desc_mem(struct s_smc
*smc
, u_int size
);
120 unsigned long mac_drv_virt2phys(struct s_smc
*smc
, void *virt
);
121 unsigned long dma_master(struct s_smc
*smc
, void *virt
, int len
, int flag
);
122 void dma_complete(struct s_smc
*smc
, volatile union s_fp_descr
*descr
,
124 void mac_drv_tx_complete(struct s_smc
*smc
, volatile struct s_smt_fp_txd
*txd
);
125 void llc_restart_tx(struct s_smc
*smc
);
126 void mac_drv_rx_complete(struct s_smc
*smc
, volatile struct s_smt_fp_rxd
*rxd
,
127 int frag_count
, int len
);
128 void mac_drv_requeue_rxd(struct s_smc
*smc
, volatile struct s_smt_fp_rxd
*rxd
,
130 void mac_drv_fill_rxd(struct s_smc
*smc
);
131 void mac_drv_clear_rxd(struct s_smc
*smc
, volatile struct s_smt_fp_rxd
*rxd
,
133 int mac_drv_rx_init(struct s_smc
*smc
, int len
, int fc
, char *look_ahead
,
135 void dump_data(unsigned char *Data
, int length
);
137 // External functions from the hardware module
138 extern u_int
mac_drv_check_space(void);
139 extern int mac_drv_init(struct s_smc
*smc
);
140 extern void hwm_tx_frag(struct s_smc
*smc
, char far
* virt
, u_long phys
,
141 int len
, int frame_status
);
142 extern int hwm_tx_init(struct s_smc
*smc
, u_char fc
, int frag_count
,
143 int frame_len
, int frame_status
);
144 extern void fddi_isr(struct s_smc
*smc
);
145 extern void hwm_rx_frag(struct s_smc
*smc
, char far
* virt
, u_long phys
,
146 int len
, int frame_status
);
147 extern void mac_drv_rx_mode(struct s_smc
*smc
, int mode
);
148 extern void mac_drv_clear_rx_queue(struct s_smc
*smc
);
149 extern void enable_tx_irq(struct s_smc
*smc
, u_short queue
);
151 static const struct pci_device_id skfddi_pci_tbl
[] = {
152 { PCI_VENDOR_ID_SK
, PCI_DEVICE_ID_SK_FP
, PCI_ANY_ID
, PCI_ANY_ID
, },
153 { } /* Terminating entry */
155 MODULE_DEVICE_TABLE(pci
, skfddi_pci_tbl
);
156 MODULE_DESCRIPTION("SysKonnect FDDI PCI driver");
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_set_rx_mode
= skfp_ctl_set_multicast_list
,
170 .ndo_set_mac_address
= skfp_ctl_set_mac_address
,
171 .ndo_siocdevprivate
= skfp_siocdevprivate
,
180 * Probes for supported FDDI PCI controllers
186 * pdev - pointer to PCI device information
188 * Functional Description:
189 * This is now called by PCI driver registration process
190 * for each board found.
193 * 0 - This device (fddi0, fddi1, etc) configured successfully
194 * -ENODEV - No devices present, or no SysKonnect FDDI PCI device
195 * present for this device name
199 * Device structures for FDDI adapters (fddi0, fddi1, etc) are
200 * initialized and the board resources are read and stored in
201 * the device structure.
203 static int skfp_init_one(struct pci_dev
*pdev
,
204 const struct pci_device_id
*ent
)
206 struct net_device
*dev
;
207 struct s_smc
*smc
; /* board pointer */
211 pr_debug("entering skfp_init_one\n");
214 printk("%s\n", boot_msg
);
216 err
= pci_enable_device(pdev
);
220 err
= pci_request_regions(pdev
, "skfddi");
224 pci_set_master(pdev
);
227 if (!(pci_resource_flags(pdev
, 0) & IORESOURCE_MEM
)) {
228 printk(KERN_ERR
"skfp: region is not an MMIO resource\n");
233 mem
= ioremap(pci_resource_start(pdev
, 0), 0x4000);
235 if (!(pci_resource_flags(pdev
, 1) & IO_RESOURCE_IO
)) {
236 printk(KERN_ERR
"skfp: region is not PIO resource\n");
241 mem
= ioport_map(pci_resource_start(pdev
, 1), FP_IO_LEN
);
244 printk(KERN_ERR
"skfp: Unable to map register, "
245 "FDDI adapter will be disabled.\n");
250 dev
= alloc_fddidev(sizeof(struct s_smc
));
252 printk(KERN_ERR
"skfp: Unable to allocate fddi device, "
253 "FDDI adapter will be disabled.\n");
258 dev
->irq
= pdev
->irq
;
259 dev
->netdev_ops
= &skfp_netdev_ops
;
261 SET_NETDEV_DEV(dev
, &pdev
->dev
);
263 /* Initialize board structure with bus-specific info */
264 smc
= netdev_priv(dev
);
266 smc
->os
.bus_type
= SK_BUS_TYPE_PCI
;
267 smc
->os
.pdev
= *pdev
;
268 smc
->os
.QueueSkb
= MAX_TX_QUEUE_LEN
;
269 smc
->os
.MaxFrameSize
= MAX_FRAME_SIZE
;
273 smc
->os
.ResetRequested
= FALSE
;
274 skb_queue_head_init(&smc
->os
.SendSkbQueue
);
276 dev
->base_addr
= (unsigned long)mem
;
278 err
= skfp_driver_init(dev
);
282 err
= register_netdev(dev
);
287 pci_set_drvdata(pdev
, dev
);
289 if ((pdev
->subsystem_device
& 0xff00) == 0x5500 ||
290 (pdev
->subsystem_device
& 0xff00) == 0x5800)
291 printk("%s: SysKonnect FDDI PCI adapter"
292 " found (SK-%04X)\n", dev
->name
,
293 pdev
->subsystem_device
);
295 printk("%s: FDDI PCI adapter found\n", dev
->name
);
299 if (smc
->os
.SharedMemAddr
)
300 dma_free_coherent(&pdev
->dev
, smc
->os
.SharedMemSize
,
301 smc
->os
.SharedMemAddr
,
302 smc
->os
.SharedMemDMA
);
303 dma_free_coherent(&pdev
->dev
, MAX_FRAME_SIZE
,
304 smc
->os
.LocalRxBuffer
, smc
->os
.LocalRxBufferDMA
);
314 pci_release_regions(pdev
);
316 pci_disable_device(pdev
);
321 * Called for each adapter board from pci_unregister_driver
323 static void skfp_remove_one(struct pci_dev
*pdev
)
325 struct net_device
*p
= pci_get_drvdata(pdev
);
326 struct s_smc
*lp
= netdev_priv(p
);
328 unregister_netdev(p
);
330 if (lp
->os
.SharedMemAddr
) {
331 dma_free_coherent(&pdev
->dev
,
332 lp
->os
.SharedMemSize
,
333 lp
->os
.SharedMemAddr
,
334 lp
->os
.SharedMemDMA
);
335 lp
->os
.SharedMemAddr
= NULL
;
337 if (lp
->os
.LocalRxBuffer
) {
338 dma_free_coherent(&pdev
->dev
,
340 lp
->os
.LocalRxBuffer
,
341 lp
->os
.LocalRxBufferDMA
);
342 lp
->os
.LocalRxBuffer
= NULL
;
347 ioport_unmap(lp
->hw
.iop
);
349 pci_release_regions(pdev
);
352 pci_disable_device(pdev
);
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("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
= dma_alloc_coherent(&bp
->pdev
.dev
, MAX_FRAME_SIZE
,
398 &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
= dma_alloc_coherent(&bp
->pdev
.dev
,
416 if (!bp
->SharedMemAddr
) {
417 printk("could not allocate mem for ");
418 printk("hardware module: %ld byte\n",
424 bp
->SharedMemAddr
= NULL
;
427 bp
->SharedMemHeap
= 0;
429 card_stop(smc
); // Reset adapter.
431 pr_debug("mac_drv_init()..\n");
432 if (mac_drv_init(smc
) != 0) {
433 pr_debug("mac_drv_init() failed\n");
436 read_address(smc
, NULL
);
437 pr_debug("HW-Addr: %pMF\n", smc
->hw
.fddi_canon_addr
.a
);
438 eth_hw_addr_set(dev
, smc
->hw
.fddi_canon_addr
.a
);
440 smt_reset_defaults(smc
, 0);
445 if (bp
->SharedMemAddr
) {
446 dma_free_coherent(&bp
->pdev
.dev
,
450 bp
->SharedMemAddr
= NULL
;
452 if (bp
->LocalRxBuffer
) {
453 dma_free_coherent(&bp
->pdev
.dev
, MAX_FRAME_SIZE
,
454 bp
->LocalRxBuffer
, bp
->LocalRxBufferDMA
);
455 bp
->LocalRxBuffer
= NULL
;
458 } // skfp_driver_init
473 * dev - pointer to device information
475 * Functional Description:
476 * This function brings the adapter to an operational state.
479 * 0 - Adapter was successfully opened
480 * -EAGAIN - Could not register IRQ
482 static int skfp_open(struct net_device
*dev
)
484 struct s_smc
*smc
= netdev_priv(dev
);
487 pr_debug("entering skfp_open\n");
488 /* Register IRQ - support shared interrupts by passing device ptr */
489 err
= request_irq(dev
->irq
, skfp_interrupt
, IRQF_SHARED
,
495 * Set current address to factory MAC address
497 * Note: We've already done this step in skfp_driver_init.
498 * However, it's possible that a user has set a node
499 * address override, then closed and reopened the
500 * adapter. Unless we reset the device address field
501 * now, we'll continue to use the existing modified
504 read_address(smc
, NULL
);
505 eth_hw_addr_set(dev
, smc
->hw
.fddi_canon_addr
.a
);
511 /* Clear local multicast address tables */
512 mac_clear_multicast(smc
);
514 /* Disable promiscuous filter settings */
515 mac_drv_rx_mode(smc
, RX_DISABLE_PROMISC
);
517 netif_start_queue(dev
);
528 * Closes the device/module.
534 * dev - pointer to device information
536 * Functional Description:
537 * This routine closes the adapter and brings it to a safe state.
538 * The interrupt service routine is deregistered with the OS.
539 * The adapter can be opened again with another call to skfp_open().
545 * No further requests for this adapter are made after this routine is
546 * called. skfp_open() can be called to reset and reinitialize the
549 static int skfp_close(struct net_device
*dev
)
551 struct s_smc
*smc
= netdev_priv(dev
);
552 skfddi_priv
*bp
= &smc
->os
;
555 smt_reset_defaults(smc
, 1);
557 mac_drv_clear_tx_queue(smc
);
558 mac_drv_clear_rx_queue(smc
);
560 netif_stop_queue(dev
);
561 /* Deregister (free) IRQ */
562 free_irq(dev
->irq
, dev
);
564 skb_queue_purge(&bp
->SendSkbQueue
);
565 bp
->QueueSkb
= MAX_TX_QUEUE_LEN
;
577 * Interrupt processing routine
583 * irq - interrupt vector
584 * dev_id - pointer to device information
586 * Functional Description:
587 * This routine calls the interrupt processing routine for this adapter. It
588 * disables and reenables adapter interrupts, as appropriate. We can support
589 * shared interrupts since the incoming dev_id pointer provides our device
590 * structure context. All the real work is done in the hardware module.
596 * The interrupt acknowledgement at the hardware level (eg. ACKing the PIC
597 * on Intel-based systems) is done by the operating system outside this
600 * System interrupts are enabled through this call.
603 * Interrupts are disabled, then reenabled at the adapter.
606 static irqreturn_t
skfp_interrupt(int irq
, void *dev_id
)
608 struct net_device
*dev
= dev_id
;
609 struct s_smc
*smc
; /* private board structure pointer */
612 smc
= netdev_priv(dev
);
615 // IRQs enabled or disabled ?
616 if (inpd(ADDR(B0_IMSK
)) == 0) {
617 // IRQs are disabled: must be shared interrupt
620 // Note: At this point, IRQs are enabled.
621 if ((inpd(ISR_A
) & smc
->hw
.is_imask
) == 0) { // IRQ?
622 // Adapter did not issue an IRQ: must be shared interrupt
625 CLI_FBI(); // Disable IRQs from our adapter.
626 spin_lock(&bp
->DriverLock
);
628 // Call interrupt handler in hardware module (HWM).
631 if (smc
->os
.ResetRequested
) {
633 smc
->os
.ResetRequested
= FALSE
;
635 spin_unlock(&bp
->DriverLock
);
636 STI_FBI(); // Enable IRQs from our adapter.
643 * ======================
644 * = skfp_ctl_get_stats =
645 * ======================
648 * Get statistics for FDDI adapter
651 * Pointer to FDDI statistics structure
654 * dev - pointer to device information
656 * Functional Description:
657 * Gets current MIB objects from adapter, then
658 * returns FDDI statistics structure as defined
661 * Note: Since the FDDI statistics structure is
662 * still new and the device structure doesn't
663 * have an FDDI-specific get statistics handler,
664 * we'll return the FDDI statistics structure as
665 * a pointer to an Ethernet statistics structure.
666 * That way, at least the first part of the statistics
667 * structure can be decoded properly.
668 * We'll have to pay attention to this routine as the
669 * device structure becomes more mature and LAN media
673 static struct net_device_stats
*skfp_ctl_get_stats(struct net_device
*dev
)
675 struct s_smc
*bp
= netdev_priv(dev
);
677 /* Fill the bp->stats structure with driver-maintained counters */
679 bp
->os
.MacStat
.port_bs_flag
[0] = 0x1234;
680 bp
->os
.MacStat
.port_bs_flag
[1] = 0x5678;
681 // goos: need to fill out fddi statistic
683 /* Get FDDI SMT MIB objects */
685 /* Fill the bp->stats structure with the SMT MIB object values */
687 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
));
688 bp
->stats
.smt_op_version_id
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_op_version_id
;
689 bp
->stats
.smt_hi_version_id
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_hi_version_id
;
690 bp
->stats
.smt_lo_version_id
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_lo_version_id
;
691 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
));
692 bp
->stats
.smt_mib_version_id
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_mib_version_id
;
693 bp
->stats
.smt_mac_cts
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_mac_ct
;
694 bp
->stats
.smt_non_master_cts
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_non_master_ct
;
695 bp
->stats
.smt_master_cts
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_master_ct
;
696 bp
->stats
.smt_available_paths
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_available_paths
;
697 bp
->stats
.smt_config_capabilities
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_config_capabilities
;
698 bp
->stats
.smt_config_policy
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_config_policy
;
699 bp
->stats
.smt_connection_policy
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_connection_policy
;
700 bp
->stats
.smt_t_notify
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_t_notify
;
701 bp
->stats
.smt_stat_rpt_policy
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_stat_rpt_policy
;
702 bp
->stats
.smt_trace_max_expiration
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_trace_max_expiration
;
703 bp
->stats
.smt_bypass_present
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_bypass_present
;
704 bp
->stats
.smt_ecm_state
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_ecm_state
;
705 bp
->stats
.smt_cf_state
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_cf_state
;
706 bp
->stats
.smt_remote_disconnect_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_remote_disconnect_flag
;
707 bp
->stats
.smt_station_status
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_station_status
;
708 bp
->stats
.smt_peer_wrap_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_peer_wrap_flag
;
709 bp
->stats
.smt_time_stamp
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_msg_time_stamp
.ls
;
710 bp
->stats
.smt_transition_time_stamp
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_transition_time_stamp
.ls
;
711 bp
->stats
.mac_frame_status_functions
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_frame_status_functions
;
712 bp
->stats
.mac_t_max_capability
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_t_max_capability
;
713 bp
->stats
.mac_tvx_capability
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_tvx_capability
;
714 bp
->stats
.mac_available_paths
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_available_paths
;
715 bp
->stats
.mac_current_path
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_current_path
;
716 memcpy(bp
->stats
.mac_upstream_nbr
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_upstream_nbr
, FDDI_K_ALEN
);
717 memcpy(bp
->stats
.mac_downstream_nbr
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_downstream_nbr
, FDDI_K_ALEN
);
718 memcpy(bp
->stats
.mac_old_upstream_nbr
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_old_upstream_nbr
, FDDI_K_ALEN
);
719 memcpy(bp
->stats
.mac_old_downstream_nbr
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_old_downstream_nbr
, FDDI_K_ALEN
);
720 bp
->stats
.mac_dup_address_test
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_dup_address_test
;
721 bp
->stats
.mac_requested_paths
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_requested_paths
;
722 bp
->stats
.mac_downstream_port_type
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_downstream_port_type
;
723 memcpy(bp
->stats
.mac_smt_address
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_smt_address
, FDDI_K_ALEN
);
724 bp
->stats
.mac_t_req
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_t_req
;
725 bp
->stats
.mac_t_neg
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_t_neg
;
726 bp
->stats
.mac_t_max
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_t_max
;
727 bp
->stats
.mac_tvx_value
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_tvx_value
;
728 bp
->stats
.mac_frame_error_threshold
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_frame_error_threshold
;
729 bp
->stats
.mac_frame_error_ratio
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_frame_error_ratio
;
730 bp
->stats
.mac_rmt_state
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_rmt_state
;
731 bp
->stats
.mac_da_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_da_flag
;
732 bp
->stats
.mac_una_da_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_unda_flag
;
733 bp
->stats
.mac_frame_error_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_frame_error_flag
;
734 bp
->stats
.mac_ma_unitdata_available
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_ma_unitdata_available
;
735 bp
->stats
.mac_hardware_present
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_hardware_present
;
736 bp
->stats
.mac_ma_unitdata_enable
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_ma_unitdata_enable
;
737 bp
->stats
.path_tvx_lower_bound
= bp
->cmd_rsp_virt
->smt_mib_get
.path_tvx_lower_bound
;
738 bp
->stats
.path_t_max_lower_bound
= bp
->cmd_rsp_virt
->smt_mib_get
.path_t_max_lower_bound
;
739 bp
->stats
.path_max_t_req
= bp
->cmd_rsp_virt
->smt_mib_get
.path_max_t_req
;
740 memcpy(bp
->stats
.path_configuration
, &bp
->cmd_rsp_virt
->smt_mib_get
.path_configuration
, sizeof(bp
->cmd_rsp_virt
->smt_mib_get
.path_configuration
));
741 bp
->stats
.port_my_type
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_my_type
[0];
742 bp
->stats
.port_my_type
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_my_type
[1];
743 bp
->stats
.port_neighbor_type
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_neighbor_type
[0];
744 bp
->stats
.port_neighbor_type
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_neighbor_type
[1];
745 bp
->stats
.port_connection_policies
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connection_policies
[0];
746 bp
->stats
.port_connection_policies
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connection_policies
[1];
747 bp
->stats
.port_mac_indicated
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_mac_indicated
[0];
748 bp
->stats
.port_mac_indicated
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_mac_indicated
[1];
749 bp
->stats
.port_current_path
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_current_path
[0];
750 bp
->stats
.port_current_path
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_current_path
[1];
751 memcpy(&bp
->stats
.port_requested_paths
[0 * 3], &bp
->cmd_rsp_virt
->smt_mib_get
.port_requested_paths
[0], 3);
752 memcpy(&bp
->stats
.port_requested_paths
[1 * 3], &bp
->cmd_rsp_virt
->smt_mib_get
.port_requested_paths
[1], 3);
753 bp
->stats
.port_mac_placement
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_mac_placement
[0];
754 bp
->stats
.port_mac_placement
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_mac_placement
[1];
755 bp
->stats
.port_available_paths
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_available_paths
[0];
756 bp
->stats
.port_available_paths
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_available_paths
[1];
757 bp
->stats
.port_pmd_class
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pmd_class
[0];
758 bp
->stats
.port_pmd_class
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pmd_class
[1];
759 bp
->stats
.port_connection_capabilities
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connection_capabilities
[0];
760 bp
->stats
.port_connection_capabilities
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connection_capabilities
[1];
761 bp
->stats
.port_bs_flag
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_bs_flag
[0];
762 bp
->stats
.port_bs_flag
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_bs_flag
[1];
763 bp
->stats
.port_ler_estimate
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_estimate
[0];
764 bp
->stats
.port_ler_estimate
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_estimate
[1];
765 bp
->stats
.port_ler_cutoff
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_cutoff
[0];
766 bp
->stats
.port_ler_cutoff
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_cutoff
[1];
767 bp
->stats
.port_ler_alarm
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_alarm
[0];
768 bp
->stats
.port_ler_alarm
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_alarm
[1];
769 bp
->stats
.port_connect_state
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connect_state
[0];
770 bp
->stats
.port_connect_state
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connect_state
[1];
771 bp
->stats
.port_pcm_state
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pcm_state
[0];
772 bp
->stats
.port_pcm_state
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pcm_state
[1];
773 bp
->stats
.port_pc_withhold
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pc_withhold
[0];
774 bp
->stats
.port_pc_withhold
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pc_withhold
[1];
775 bp
->stats
.port_ler_flag
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_flag
[0];
776 bp
->stats
.port_ler_flag
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_flag
[1];
777 bp
->stats
.port_hardware_present
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_hardware_present
[0];
778 bp
->stats
.port_hardware_present
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_hardware_present
[1];
781 /* Fill the bp->stats structure with the FDDI counter values */
783 bp
->stats
.mac_frame_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.frame_cnt
.ls
;
784 bp
->stats
.mac_copied_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.copied_cnt
.ls
;
785 bp
->stats
.mac_transmit_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.transmit_cnt
.ls
;
786 bp
->stats
.mac_error_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.error_cnt
.ls
;
787 bp
->stats
.mac_lost_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lost_cnt
.ls
;
788 bp
->stats
.port_lct_fail_cts
[0] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lct_rejects
[0].ls
;
789 bp
->stats
.port_lct_fail_cts
[1] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lct_rejects
[1].ls
;
790 bp
->stats
.port_lem_reject_cts
[0] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lem_rejects
[0].ls
;
791 bp
->stats
.port_lem_reject_cts
[1] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lem_rejects
[1].ls
;
792 bp
->stats
.port_lem_cts
[0] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.link_errors
[0].ls
;
793 bp
->stats
.port_lem_cts
[1] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.link_errors
[1].ls
;
796 return (struct net_device_stats
*)&bp
->os
.MacStat
;
801 * ==============================
802 * = skfp_ctl_set_multicast_list =
803 * ==============================
806 * Enable/Disable LLC frame promiscuous mode reception
807 * on the adapter and/or update multicast address table.
813 * dev - pointer to device information
815 * Functional Description:
816 * This function acquires the driver lock and only calls
817 * skfp_ctl_set_multicast_list_wo_lock then.
818 * This routine follows a fairly simple algorithm for setting the
819 * adapter filters and CAM:
821 * if IFF_PROMISC flag is set
822 * enable promiscuous mode
824 * disable promiscuous mode
825 * if number of multicast addresses <= max. multicast number
826 * add mc addresses to adapter table
828 * enable promiscuous mode
829 * update adapter filters
832 * Multicast addresses are presented in canonical (LSB) format.
835 * On-board adapter filters are updated.
837 static void skfp_ctl_set_multicast_list(struct net_device
*dev
)
839 struct s_smc
*smc
= netdev_priv(dev
);
840 skfddi_priv
*bp
= &smc
->os
;
843 spin_lock_irqsave(&bp
->DriverLock
, Flags
);
844 skfp_ctl_set_multicast_list_wo_lock(dev
);
845 spin_unlock_irqrestore(&bp
->DriverLock
, Flags
);
846 } // skfp_ctl_set_multicast_list
850 static void skfp_ctl_set_multicast_list_wo_lock(struct net_device
*dev
)
852 struct s_smc
*smc
= netdev_priv(dev
);
853 struct netdev_hw_addr
*ha
;
855 /* Enable promiscuous mode, if necessary */
856 if (dev
->flags
& IFF_PROMISC
) {
857 mac_drv_rx_mode(smc
, RX_ENABLE_PROMISC
);
858 pr_debug("PROMISCUOUS MODE ENABLED\n");
860 /* Else, update multicast address table */
862 mac_drv_rx_mode(smc
, RX_DISABLE_PROMISC
);
863 pr_debug("PROMISCUOUS MODE DISABLED\n");
865 // Reset all MC addresses
866 mac_clear_multicast(smc
);
867 mac_drv_rx_mode(smc
, RX_DISABLE_ALLMULTI
);
869 if (dev
->flags
& IFF_ALLMULTI
) {
870 mac_drv_rx_mode(smc
, RX_ENABLE_ALLMULTI
);
871 pr_debug("ENABLE ALL MC ADDRESSES\n");
872 } else if (!netdev_mc_empty(dev
)) {
873 if (netdev_mc_count(dev
) <= FPMAX_MULTICAST
) {
874 /* use exact filtering */
876 // point to first multicast addr
877 netdev_for_each_mc_addr(ha
, dev
) {
878 mac_add_multicast(smc
,
879 (struct fddi_addr
*)ha
->addr
,
882 pr_debug("ENABLE MC ADDRESS: %pMF\n",
886 } else { // more MC addresses than HW supports
888 mac_drv_rx_mode(smc
, RX_ENABLE_ALLMULTI
);
889 pr_debug("ENABLE ALL MC ADDRESSES\n");
891 } else { // no MC addresses
893 pr_debug("DISABLE ALL MC ADDRESSES\n");
896 /* Update adapter filters */
897 mac_update_multicast(smc
);
899 } // skfp_ctl_set_multicast_list_wo_lock
903 * ===========================
904 * = skfp_ctl_set_mac_address =
905 * ===========================
908 * set new mac address on adapter and update dev_addr field in device table.
914 * dev - pointer to device information
915 * addr - pointer to sockaddr structure containing unicast address to set
918 * The address pointed to by addr->sa_data is a valid unicast
919 * address and is presented in canonical (LSB) format.
921 static int skfp_ctl_set_mac_address(struct net_device
*dev
, void *addr
)
923 struct s_smc
*smc
= netdev_priv(dev
);
924 struct sockaddr
*p_sockaddr
= (struct sockaddr
*) addr
;
925 skfddi_priv
*bp
= &smc
->os
;
929 dev_addr_set(dev
, p_sockaddr
->sa_data
);
930 spin_lock_irqsave(&bp
->DriverLock
, Flags
);
932 spin_unlock_irqrestore(&bp
->DriverLock
, Flags
);
934 return 0; /* always return zero */
935 } // skfp_ctl_set_mac_address
939 * =======================
940 * = skfp_siocdevprivate =
941 * =======================
945 * Perform IOCTL call functions here. Some are privileged operations and the
946 * effective uid is checked in those cases.
954 * dev - pointer to device information
955 * rq - pointer to ioctl request structure
961 static int skfp_siocdevprivate(struct net_device
*dev
, struct ifreq
*rq
, void __user
*data
, int cmd
)
963 struct s_smc
*smc
= netdev_priv(dev
);
964 skfddi_priv
*lp
= &smc
->os
;
965 struct s_skfp_ioctl ioc
;
968 if (copy_from_user(&ioc
, data
, sizeof(struct s_skfp_ioctl
)))
971 if (in_compat_syscall())
975 case SKFP_GET_STATS
: /* Get the driver statistics */
976 ioc
.len
= sizeof(lp
->MacStat
);
977 status
= copy_to_user(ioc
.data
, skfp_ctl_get_stats(dev
), ioc
.len
)
980 case SKFP_CLR_STATS
: /* Zero out the driver statistics */
981 if (!capable(CAP_NET_ADMIN
)) {
984 memset(&lp
->MacStat
, 0, sizeof(lp
->MacStat
));
988 printk("ioctl for %s: unknown cmd: %04x\n", dev
->name
, ioc
.cmd
);
989 status
= -EOPNOTSUPP
;
998 * =====================
1000 * =====================
1003 * Queues a packet for transmission and try to transmit it.
1009 * skb - pointer to sk_buff to queue for transmission
1010 * dev - pointer to device information
1012 * Functional Description:
1013 * Here we assume that an incoming skb transmit request
1014 * is contained in a single physically contiguous buffer
1015 * in which the virtual address of the start of packet
1016 * (skb->data) can be converted to a physical address
1017 * by using dma_map_single().
1019 * We have an internal queue for packets we can not send
1020 * immediately. Packets in this queue can be given to the
1021 * adapter if transmit buffers are freed.
1023 * We can't free the skb until after it's been DMA'd
1024 * out by the adapter, so we'll keep it in the driver and
1025 * return it in mac_drv_tx_complete.
1028 * 0 - driver has queued and/or sent packet
1029 * 1 - caller should requeue the sk_buff for later transmission
1032 * The entire packet is stored in one physically
1033 * contiguous buffer which is not cached and whose
1034 * 32-bit physical address can be determined.
1036 * It's vital that this routine is NOT reentered for the
1037 * same board and that the OS is not in another section of
1038 * code (eg. skfp_interrupt) for the same board on a
1044 static netdev_tx_t
skfp_send_pkt(struct sk_buff
*skb
,
1045 struct net_device
*dev
)
1047 struct s_smc
*smc
= netdev_priv(dev
);
1048 skfddi_priv
*bp
= &smc
->os
;
1050 pr_debug("skfp_send_pkt\n");
1053 * Verify that incoming transmit request is OK
1055 * Note: The packet size check is consistent with other
1056 * Linux device drivers, although the correct packet
1057 * size should be verified before calling the
1061 if (!(skb
->len
>= FDDI_K_LLC_ZLEN
&& skb
->len
<= FDDI_K_LLC_LEN
)) {
1062 bp
->MacStat
.gen
.tx_errors
++; /* bump error counter */
1063 // dequeue packets from xmt queue and send them
1064 netif_start_queue(dev
);
1066 return NETDEV_TX_OK
; /* return "success" */
1068 if (bp
->QueueSkb
== 0) { // return with tbusy set: queue full
1070 netif_stop_queue(dev
);
1071 return NETDEV_TX_BUSY
;
1074 skb_queue_tail(&bp
->SendSkbQueue
, skb
);
1075 send_queued_packets(netdev_priv(dev
));
1076 if (bp
->QueueSkb
== 0) {
1077 netif_stop_queue(dev
);
1079 return NETDEV_TX_OK
;
1085 * =======================
1086 * = send_queued_packets =
1087 * =======================
1090 * Send packets from the driver queue as long as there are some and
1091 * transmit resources are available.
1097 * smc - pointer to smc (adapter) structure
1099 * Functional Description:
1100 * Take a packet from queue if there is any. If not, then we are done.
1101 * Check if there are resources to send the packet. If not, requeue it
1103 * Set packet descriptor flags and give packet to adapter.
1104 * Check if any send resources can be freed (we do not use the
1105 * transmit complete interrupt).
1107 static void send_queued_packets(struct s_smc
*smc
)
1109 skfddi_priv
*bp
= &smc
->os
;
1110 struct sk_buff
*skb
;
1113 struct s_smt_fp_txd
*txd
; // Current TxD.
1114 dma_addr_t dma_address
;
1115 unsigned long Flags
;
1117 int frame_status
; // HWM tx frame status.
1119 pr_debug("send queued packets\n");
1121 // send first buffer from queue
1122 skb
= skb_dequeue(&bp
->SendSkbQueue
);
1125 pr_debug("queue empty\n");
1129 spin_lock_irqsave(&bp
->DriverLock
, Flags
);
1131 queue
= (fc
& FC_SYNC_BIT
) ? QUEUE_S
: QUEUE_A0
;
1133 // Check if the frame may/must be sent as a synchronous frame.
1135 if ((fc
& ~(FC_SYNC_BIT
| FC_LLC_PRIOR
)) == FC_ASYNC_LLC
) {
1136 // It's an LLC frame.
1137 if (!smc
->ess
.sync_bw_available
)
1138 fc
&= ~FC_SYNC_BIT
; // No bandwidth available.
1140 else { // Bandwidth is available.
1142 if (smc
->mib
.fddiESSSynchTxMode
) {
1143 // Send as sync. frame.
1149 frame_status
= hwm_tx_init(smc
, fc
, 1, skb
->len
, queue
);
1151 if ((frame_status
& (LOC_TX
| LAN_TX
)) == 0) {
1152 // Unable to send the frame.
1154 if ((frame_status
& RING_DOWN
) != 0) {
1156 pr_debug("Tx attempt while ring down.\n");
1157 } else if ((frame_status
& OUT_OF_TXD
) != 0) {
1158 pr_debug("%s: out of TXDs.\n", bp
->dev
->name
);
1160 pr_debug("%s: out of transmit resources",
1164 // Note: We will retry the operation as soon as
1165 // transmit resources become available.
1166 skb_queue_head(&bp
->SendSkbQueue
, skb
);
1167 spin_unlock_irqrestore(&bp
->DriverLock
, Flags
);
1168 return; // Packet has been queued.
1170 } // if (unable to send frame)
1172 bp
->QueueSkb
++; // one packet less in local queue
1174 // source address in packet ?
1175 CheckSourceAddress(skb
->data
, smc
->hw
.fddi_canon_addr
.a
);
1177 txd
= (struct s_smt_fp_txd
*) HWM_GET_CURR_TXD(smc
, queue
);
1179 dma_address
= dma_map_single(&(&bp
->pdev
)->dev
, skb
->data
,
1180 skb
->len
, DMA_TO_DEVICE
);
1181 if (frame_status
& LAN_TX
) {
1182 txd
->txd_os
.skb
= skb
; // save skb
1183 txd
->txd_os
.dma_addr
= dma_address
; // save dma mapping
1185 hwm_tx_frag(smc
, skb
->data
, dma_address
, skb
->len
,
1186 frame_status
| FIRST_FRAG
| LAST_FRAG
| EN_IRQ_EOF
);
1188 if (!(frame_status
& LAN_TX
)) { // local only frame
1189 dma_unmap_single(&(&bp
->pdev
)->dev
, dma_address
,
1190 skb
->len
, DMA_TO_DEVICE
);
1191 dev_kfree_skb_irq(skb
);
1193 spin_unlock_irqrestore(&bp
->DriverLock
, Flags
);
1196 return; // never reached
1198 } // send_queued_packets
1201 /************************
1203 * CheckSourceAddress
1205 * Verify if the source address is set. Insert it if necessary.
1207 ************************/
1208 static void CheckSourceAddress(unsigned char *frame
, unsigned char *hw_addr
)
1210 unsigned char SRBit
;
1212 if ((((unsigned long) frame
[1 + 6]) & ~0x01) != 0) // source routing bit
1215 if ((unsigned short) frame
[1 + 10] != 0)
1217 SRBit
= frame
[1 + 6] & 0x01;
1218 memcpy(&frame
[1 + 6], hw_addr
, ETH_ALEN
);
1220 } // CheckSourceAddress
1223 /************************
1227 * Reset the adapter and bring it back to operational mode.
1229 * smc - A pointer to the SMT context struct.
1233 ************************/
1234 static void ResetAdapter(struct s_smc
*smc
)
1237 pr_debug("[fddi: ResetAdapter]\n");
1239 // Stop the adapter.
1241 card_stop(smc
); // Stop all activity.
1243 // Clear the transmit and receive descriptor queues.
1244 mac_drv_clear_tx_queue(smc
);
1245 mac_drv_clear_rx_queue(smc
);
1247 // Restart the adapter.
1249 smt_reset_defaults(smc
, 1); // Initialize the SMT module.
1251 init_smt(smc
, (smc
->os
.dev
)->dev_addr
); // Initialize the hardware.
1253 smt_online(smc
, 1); // Insert into the ring again.
1256 // Restore original receive mode (multicasts, promiscuous, etc.).
1257 skfp_ctl_set_multicast_list_wo_lock(smc
->os
.dev
);
1261 //--------------- functions called by hardware module ----------------
1263 /************************
1267 * The hardware driver calls this routine when the transmit complete
1268 * interrupt bits (end of frame) for the synchronous or asynchronous
1271 * NOTE The hardware driver calls this function also if no packets are queued.
1272 * The routine must be able to handle this case.
1274 * smc - A pointer to the SMT context struct.
1278 ************************/
1279 void llc_restart_tx(struct s_smc
*smc
)
1281 skfddi_priv
*bp
= &smc
->os
;
1283 pr_debug("[llc_restart_tx]\n");
1285 // Try to send queued packets
1286 spin_unlock(&bp
->DriverLock
);
1287 send_queued_packets(smc
);
1288 spin_lock(&bp
->DriverLock
);
1289 netif_start_queue(bp
->dev
);// system may send again if it was blocked
1294 /************************
1298 * The hardware module calls this function to allocate the memory
1299 * for the SMT MBufs if the define MB_OUTSIDE_SMC is specified.
1301 * smc - A pointer to the SMT context struct.
1303 * size - Size of memory in bytes to allocate.
1305 * != 0 A pointer to the virtual address of the allocated memory.
1306 * == 0 Allocation error.
1308 ************************/
1309 void *mac_drv_get_space(struct s_smc
*smc
, unsigned int size
)
1313 pr_debug("mac_drv_get_space (%d bytes), ", size
);
1314 virt
= (void *) (smc
->os
.SharedMemAddr
+ smc
->os
.SharedMemHeap
);
1316 if ((smc
->os
.SharedMemHeap
+ size
) > smc
->os
.SharedMemSize
) {
1317 printk("Unexpected SMT memory size requested: %d\n", size
);
1320 smc
->os
.SharedMemHeap
+= size
; // Move heap pointer.
1322 pr_debug("mac_drv_get_space end\n");
1323 pr_debug("virt addr: %lx\n", (ulong
) virt
);
1324 pr_debug("bus addr: %lx\n", (ulong
)
1325 (smc
->os
.SharedMemDMA
+
1326 ((char *) virt
- (char *)smc
->os
.SharedMemAddr
)));
1328 } // mac_drv_get_space
1331 /************************
1333 * mac_drv_get_desc_mem
1335 * This function is called by the hardware dependent module.
1336 * It allocates the memory for the RxD and TxD descriptors.
1338 * This memory must be non-cached, non-movable and non-swappable.
1339 * This memory should start at a physical page boundary.
1341 * smc - A pointer to the SMT context struct.
1343 * size - Size of memory in bytes to allocate.
1345 * != 0 A pointer to the virtual address of the allocated memory.
1346 * == 0 Allocation error.
1348 ************************/
1349 void *mac_drv_get_desc_mem(struct s_smc
*smc
, unsigned int size
)
1354 pr_debug("mac_drv_get_desc_mem\n");
1356 // Descriptor memory must be aligned on 16-byte boundary.
1358 virt
= mac_drv_get_space(smc
, size
);
1360 size
= (u_int
) (16 - (((unsigned long) virt
) & 15UL));
1363 pr_debug("Allocate %u bytes alignment gap ", size
);
1364 pr_debug("for descriptor memory.\n");
1366 if (!mac_drv_get_space(smc
, size
)) {
1367 printk("fddi: Unable to align descriptor memory.\n");
1371 } // mac_drv_get_desc_mem
1374 /************************
1378 * Get the physical address of a given virtual address.
1380 * smc - A pointer to the SMT context struct.
1382 * virt - A (virtual) pointer into our 'shared' memory area.
1384 * Physical address of the given virtual address.
1386 ************************/
1387 unsigned long mac_drv_virt2phys(struct s_smc
*smc
, void *virt
)
1389 return smc
->os
.SharedMemDMA
+
1390 ((char *) virt
- (char *)smc
->os
.SharedMemAddr
);
1391 } // mac_drv_virt2phys
1394 /************************
1398 * The HWM calls this function, when the driver leads through a DMA
1399 * transfer. If the OS-specific module must prepare the system hardware
1400 * for the DMA transfer, it should do it in this function.
1402 * The hardware module calls this dma_master if it wants to send an SMT
1403 * frame. This means that the virt address passed in here is part of
1404 * the 'shared' memory area.
1406 * smc - A pointer to the SMT context struct.
1408 * virt - The virtual address of the data.
1410 * len - The length in bytes of the data.
1412 * flag - Indicates the transmit direction and the buffer type:
1413 * DMA_RD (0x01) system RAM ==> adapter buffer memory
1414 * DMA_WR (0x02) adapter buffer memory ==> system RAM
1415 * SMT_BUF (0x80) SMT buffer
1417 * >> NOTE: SMT_BUF and DMA_RD are always set for PCI. <<
1419 * Returns the pyhsical address for the DMA transfer.
1421 ************************/
1422 u_long
dma_master(struct s_smc
* smc
, void *virt
, int len
, int flag
)
1424 return smc
->os
.SharedMemDMA
+
1425 ((char *) virt
- (char *)smc
->os
.SharedMemAddr
);
1429 /************************
1433 * The hardware module calls this routine when it has completed a DMA
1434 * transfer. If the operating system dependent module has set up the DMA
1435 * channel via dma_master() (e.g. Windows NT or AIX) it should clean up
1438 * smc - A pointer to the SMT context struct.
1440 * descr - A pointer to a TxD or RxD, respectively.
1442 * flag - Indicates the DMA transfer direction / SMT buffer:
1443 * DMA_RD (0x01) system RAM ==> adapter buffer memory
1444 * DMA_WR (0x02) adapter buffer memory ==> system RAM
1445 * SMT_BUF (0x80) SMT buffer (managed by HWM)
1449 ************************/
1450 void dma_complete(struct s_smc
*smc
, volatile union s_fp_descr
*descr
, int flag
)
1452 /* For TX buffers, there are two cases. If it is an SMT transmit
1453 * buffer, there is nothing to do since we use consistent memory
1454 * for the 'shared' memory area. The other case is for normal
1455 * transmit packets given to us by the networking stack, and in
1456 * that case we cleanup the PCI DMA mapping in mac_drv_tx_complete
1459 * For RX buffers, we have to unmap dynamic PCI DMA mappings here
1460 * because the hardware module is about to potentially look at
1461 * the contents of the buffer. If we did not call the PCI DMA
1462 * unmap first, the hardware module could read inconsistent data.
1464 if (flag
& DMA_WR
) {
1465 skfddi_priv
*bp
= &smc
->os
;
1466 volatile struct s_smt_fp_rxd
*r
= &descr
->r
;
1468 /* If SKB is NULL, we used the local buffer. */
1469 if (r
->rxd_os
.skb
&& r
->rxd_os
.dma_addr
) {
1470 int MaxFrameSize
= bp
->MaxFrameSize
;
1472 dma_unmap_single(&(&bp
->pdev
)->dev
,
1473 r
->rxd_os
.dma_addr
, MaxFrameSize
,
1475 r
->rxd_os
.dma_addr
= 0;
1481 /************************
1483 * mac_drv_tx_complete
1485 * Transmit of a packet is complete. Release the tx staging buffer.
1488 * smc - A pointer to the SMT context struct.
1490 * txd - A pointer to the last TxD which is used by the frame.
1494 ************************/
1495 void mac_drv_tx_complete(struct s_smc
*smc
, volatile struct s_smt_fp_txd
*txd
)
1497 struct sk_buff
*skb
;
1499 pr_debug("entering mac_drv_tx_complete\n");
1500 // Check if this TxD points to a skb
1502 if (!(skb
= txd
->txd_os
.skb
)) {
1503 pr_debug("TXD with no skb assigned.\n");
1506 txd
->txd_os
.skb
= NULL
;
1508 // release the DMA mapping
1509 dma_unmap_single(&(&smc
->os
.pdev
)->dev
, txd
->txd_os
.dma_addr
,
1510 skb
->len
, DMA_TO_DEVICE
);
1511 txd
->txd_os
.dma_addr
= 0;
1513 smc
->os
.MacStat
.gen
.tx_packets
++; // Count transmitted packets.
1514 smc
->os
.MacStat
.gen
.tx_bytes
+=skb
->len
; // Count bytes
1517 dev_kfree_skb_irq(skb
);
1519 pr_debug("leaving mac_drv_tx_complete\n");
1520 } // mac_drv_tx_complete
1523 /************************
1525 * dump packets to logfile
1527 ************************/
1529 void dump_data(unsigned char *Data
, int length
)
1531 printk(KERN_INFO
"---Packet start---\n");
1532 print_hex_dump(KERN_INFO
, "", DUMP_PREFIX_NONE
, 16, 1, Data
, min_t(size_t, length
, 64), false);
1533 printk(KERN_INFO
"------------------\n");
1536 #define dump_data(data,len)
1537 #endif // DUMPPACKETS
1539 /************************
1541 * mac_drv_rx_complete
1543 * The hardware module calls this function if an LLC frame is received
1544 * in a receive buffer. Also the SMT, NSA, and directed beacon frames
1545 * from the network will be passed to the LLC layer by this function
1546 * if passing is enabled.
1548 * mac_drv_rx_complete forwards the frame to the LLC layer if it should
1549 * be received. It also fills the RxD ring with new receive buffers if
1550 * some can be queued.
1552 * smc - A pointer to the SMT context struct.
1554 * rxd - A pointer to the first RxD which is used by the receive frame.
1556 * frag_count - Count of RxDs used by the received frame.
1558 * len - Frame length.
1562 ************************/
1563 void mac_drv_rx_complete(struct s_smc
*smc
, volatile struct s_smt_fp_rxd
*rxd
,
1564 int frag_count
, int len
)
1566 skfddi_priv
*bp
= &smc
->os
;
1567 struct sk_buff
*skb
;
1568 unsigned char *virt
, *cp
;
1572 pr_debug("entering mac_drv_rx_complete (len=%d)\n", len
);
1573 if (frag_count
!= 1) { // This is not allowed to happen.
1575 printk("fddi: Multi-fragment receive!\n");
1576 goto RequeueRxd
; // Re-use the given RXD(s).
1579 skb
= rxd
->rxd_os
.skb
;
1581 pr_debug("No skb in rxd\n");
1582 smc
->os
.MacStat
.gen
.rx_errors
++;
1587 // The DMA mapping was released in dma_complete above.
1589 dump_data(skb
->data
, len
);
1592 * FDDI Frame format:
1593 * +-------+-------+-------+------------+--------+------------+
1594 * | FC[1] | DA[6] | SA[6] | RIF[0..18] | LLC[3] | Data[0..n] |
1595 * +-------+-------+-------+------------+--------+------------+
1597 * FC = Frame Control
1598 * DA = Destination Address
1599 * SA = Source Address
1600 * RIF = Routing Information Field
1601 * LLC = Logical Link Control
1604 // Remove Routing Information Field (RIF), if present.
1606 if ((virt
[1 + 6] & FDDI_RII
) == 0)
1610 // goos: RIF removal has still to be tested
1611 pr_debug("RIF found\n");
1612 // Get RIF length from Routing Control (RC) field.
1613 cp
= virt
+ FDDI_MAC_HDR_LEN
; // Point behind MAC header.
1615 ri
= ntohs(*((__be16
*) cp
));
1616 RifLength
= ri
& FDDI_RCF_LEN_MASK
;
1617 if (len
< (int) (FDDI_MAC_HDR_LEN
+ RifLength
)) {
1618 printk("fddi: Invalid RIF.\n");
1619 goto RequeueRxd
; // Discard the frame.
1622 virt
[1 + 6] &= ~FDDI_RII
; // Clear RII bit.
1625 virt
= cp
+ RifLength
;
1626 for (n
= FDDI_MAC_HDR_LEN
; n
; n
--)
1628 // adjust sbd->data pointer
1629 skb_pull(skb
, RifLength
);
1634 // Count statistics.
1635 smc
->os
.MacStat
.gen
.rx_packets
++; // Count indicated receive
1637 smc
->os
.MacStat
.gen
.rx_bytes
+=len
; // Count bytes.
1639 // virt points to header again
1640 if (virt
[1] & 0x01) { // Check group (multicast) bit.
1642 smc
->os
.MacStat
.gen
.multicast
++;
1645 // deliver frame to system
1646 rxd
->rxd_os
.skb
= NULL
;
1648 skb
->protocol
= fddi_type_trans(skb
, bp
->dev
);
1652 HWM_RX_CHECK(smc
, RX_LOW_WATERMARK
);
1656 pr_debug("Rx: re-queue RXD.\n");
1657 mac_drv_requeue_rxd(smc
, rxd
, frag_count
);
1658 smc
->os
.MacStat
.gen
.rx_errors
++; // Count receive packets
1661 } // mac_drv_rx_complete
1664 /************************
1666 * mac_drv_requeue_rxd
1668 * The hardware module calls this function to request the OS-specific
1669 * module to queue the receive buffer(s) represented by the pointer
1670 * to the RxD and the frag_count into the receive queue again. This
1671 * buffer was filled with an invalid frame or an SMT frame.
1673 * smc - A pointer to the SMT context struct.
1675 * rxd - A pointer to the first RxD which is used by the receive frame.
1677 * frag_count - Count of RxDs used by the received frame.
1681 ************************/
1682 void mac_drv_requeue_rxd(struct s_smc
*smc
, volatile struct s_smt_fp_rxd
*rxd
,
1685 volatile struct s_smt_fp_rxd
*next_rxd
;
1686 volatile struct s_smt_fp_rxd
*src_rxd
;
1687 struct sk_buff
*skb
;
1689 unsigned char *v_addr
;
1692 if (frag_count
!= 1) // This is not allowed to happen.
1694 printk("fddi: Multi-fragment requeue!\n");
1696 MaxFrameSize
= smc
->os
.MaxFrameSize
;
1698 for (; frag_count
> 0; frag_count
--) {
1699 next_rxd
= src_rxd
->rxd_next
;
1700 rxd
= HWM_GET_CURR_RXD(smc
);
1702 skb
= src_rxd
->rxd_os
.skb
;
1703 if (skb
== NULL
) { // this should not happen
1705 pr_debug("Requeue with no skb in rxd!\n");
1706 skb
= alloc_skb(MaxFrameSize
+ 3, GFP_ATOMIC
);
1709 rxd
->rxd_os
.skb
= skb
;
1710 skb_reserve(skb
, 3);
1711 skb_put(skb
, MaxFrameSize
);
1713 b_addr
= dma_map_single(&(&smc
->os
.pdev
)->dev
,
1714 v_addr
, MaxFrameSize
,
1716 rxd
->rxd_os
.dma_addr
= b_addr
;
1718 // no skb available, use local buffer
1719 pr_debug("Queueing invalid buffer!\n");
1720 rxd
->rxd_os
.skb
= NULL
;
1721 v_addr
= smc
->os
.LocalRxBuffer
;
1722 b_addr
= smc
->os
.LocalRxBufferDMA
;
1725 // we use skb from old rxd
1726 rxd
->rxd_os
.skb
= skb
;
1728 b_addr
= dma_map_single(&(&smc
->os
.pdev
)->dev
, v_addr
,
1729 MaxFrameSize
, DMA_FROM_DEVICE
);
1730 rxd
->rxd_os
.dma_addr
= b_addr
;
1732 hwm_rx_frag(smc
, v_addr
, b_addr
, MaxFrameSize
,
1733 FIRST_FRAG
| LAST_FRAG
);
1737 } // mac_drv_requeue_rxd
1740 /************************
1744 * The hardware module calls this function at initialization time
1745 * to fill the RxD ring with receive buffers. It is also called by
1746 * mac_drv_rx_complete if rx_free is large enough to queue some new
1747 * receive buffers into the RxD ring. mac_drv_fill_rxd queues new
1748 * receive buffers as long as enough RxDs and receive buffers are
1751 * smc - A pointer to the SMT context struct.
1755 ************************/
1756 void mac_drv_fill_rxd(struct s_smc
*smc
)
1759 unsigned char *v_addr
;
1760 unsigned long b_addr
;
1761 struct sk_buff
*skb
;
1762 volatile struct s_smt_fp_rxd
*rxd
;
1764 pr_debug("entering mac_drv_fill_rxd\n");
1766 // Walk through the list of free receive buffers, passing receive
1767 // buffers to the HWM as long as RXDs are available.
1769 MaxFrameSize
= smc
->os
.MaxFrameSize
;
1770 // Check if there is any RXD left.
1771 while (HWM_GET_RX_FREE(smc
) > 0) {
1774 rxd
= HWM_GET_CURR_RXD(smc
);
1775 skb
= alloc_skb(MaxFrameSize
+ 3, GFP_ATOMIC
);
1778 skb_reserve(skb
, 3);
1779 skb_put(skb
, MaxFrameSize
);
1781 b_addr
= dma_map_single(&(&smc
->os
.pdev
)->dev
, v_addr
,
1782 MaxFrameSize
, DMA_FROM_DEVICE
);
1783 rxd
->rxd_os
.dma_addr
= b_addr
;
1785 // no skb available, use local buffer
1786 // System has run out of buffer memory, but we want to
1787 // keep the receiver running in hope of better times.
1788 // Multiple descriptors may point to this local buffer,
1789 // so data in it must be considered invalid.
1790 pr_debug("Queueing invalid buffer!\n");
1791 v_addr
= smc
->os
.LocalRxBuffer
;
1792 b_addr
= smc
->os
.LocalRxBufferDMA
;
1795 rxd
->rxd_os
.skb
= skb
;
1797 // Pass receive buffer to HWM.
1798 hwm_rx_frag(smc
, v_addr
, b_addr
, MaxFrameSize
,
1799 FIRST_FRAG
| LAST_FRAG
);
1801 pr_debug("leaving mac_drv_fill_rxd\n");
1802 } // mac_drv_fill_rxd
1805 /************************
1809 * The hardware module calls this function to release unused
1812 * smc - A pointer to the SMT context struct.
1814 * rxd - A pointer to the first RxD which is used by the receive buffer.
1816 * frag_count - Count of RxDs used by the receive buffer.
1820 ************************/
1821 void mac_drv_clear_rxd(struct s_smc
*smc
, volatile struct s_smt_fp_rxd
*rxd
,
1825 struct sk_buff
*skb
;
1827 pr_debug("entering mac_drv_clear_rxd\n");
1829 if (frag_count
!= 1) // This is not allowed to happen.
1831 printk("fddi: Multi-fragment clear!\n");
1833 for (; frag_count
> 0; frag_count
--) {
1834 skb
= rxd
->rxd_os
.skb
;
1836 skfddi_priv
*bp
= &smc
->os
;
1837 int MaxFrameSize
= bp
->MaxFrameSize
;
1839 dma_unmap_single(&(&bp
->pdev
)->dev
,
1840 rxd
->rxd_os
.dma_addr
, MaxFrameSize
,
1844 rxd
->rxd_os
.skb
= NULL
;
1846 rxd
= rxd
->rxd_next
; // Next RXD.
1849 } // mac_drv_clear_rxd
1852 /************************
1856 * The hardware module calls this routine when an SMT or NSA frame of the
1857 * local SMT should be delivered to the LLC layer.
1859 * It is necessary to have this function, because there is no other way to
1860 * copy the contents of SMT MBufs into receive buffers.
1862 * mac_drv_rx_init allocates the required target memory for this frame,
1863 * and receives the frame fragment by fragment by calling mac_drv_rx_frag.
1865 * smc - A pointer to the SMT context struct.
1867 * len - The length (in bytes) of the received frame (FC, DA, SA, Data).
1869 * fc - The Frame Control field of the received frame.
1871 * look_ahead - A pointer to the lookahead data buffer (may be NULL).
1873 * la_len - The length of the lookahead data stored in the lookahead
1874 * buffer (may be zero).
1876 * Always returns zero (0).
1878 ************************/
1879 int mac_drv_rx_init(struct s_smc
*smc
, int len
, int fc
,
1880 char *look_ahead
, int la_len
)
1882 struct sk_buff
*skb
;
1884 pr_debug("entering mac_drv_rx_init(len=%d)\n", len
);
1886 // "Received" a SMT or NSA frame of the local SMT.
1888 if (len
!= la_len
|| len
< FDDI_MAC_HDR_LEN
|| !look_ahead
) {
1889 pr_debug("fddi: Discard invalid local SMT frame\n");
1890 pr_debug(" len=%d, la_len=%d, (ULONG) look_ahead=%08lXh.\n",
1891 len
, la_len
, (unsigned long) look_ahead
);
1894 skb
= alloc_skb(len
+ 3, GFP_ATOMIC
);
1896 pr_debug("fddi: Local SMT: skb memory exhausted.\n");
1899 skb_reserve(skb
, 3);
1901 skb_copy_to_linear_data(skb
, look_ahead
, len
);
1903 // deliver frame to system
1904 skb
->protocol
= fddi_type_trans(skb
, smc
->os
.dev
);
1908 } // mac_drv_rx_init
1911 /************************
1915 * This routine is called periodically by the SMT module to clean up the
1918 * Return any queued frames back to the upper protocol layers if the ring
1921 * smc - A pointer to the SMT context struct.
1925 ************************/
1926 void smt_timer_poll(struct s_smc
*smc
)
1931 /************************
1933 * ring_status_indication
1935 * This function indicates a change of the ring state.
1937 * smc - A pointer to the SMT context struct.
1939 * status - The current ring status.
1943 ************************/
1944 void ring_status_indication(struct s_smc
*smc
, u_long status
)
1946 pr_debug("ring_status_indication( ");
1947 if (status
& RS_RES15
)
1948 pr_debug("RS_RES15 ");
1949 if (status
& RS_HARDERROR
)
1950 pr_debug("RS_HARDERROR ");
1951 if (status
& RS_SOFTERROR
)
1952 pr_debug("RS_SOFTERROR ");
1953 if (status
& RS_BEACON
)
1954 pr_debug("RS_BEACON ");
1955 if (status
& RS_PATHTEST
)
1956 pr_debug("RS_PATHTEST ");
1957 if (status
& RS_SELFTEST
)
1958 pr_debug("RS_SELFTEST ");
1959 if (status
& RS_RES9
)
1960 pr_debug("RS_RES9 ");
1961 if (status
& RS_DISCONNECT
)
1962 pr_debug("RS_DISCONNECT ");
1963 if (status
& RS_RES7
)
1964 pr_debug("RS_RES7 ");
1965 if (status
& RS_DUPADDR
)
1966 pr_debug("RS_DUPADDR ");
1967 if (status
& RS_NORINGOP
)
1968 pr_debug("RS_NORINGOP ");
1969 if (status
& RS_VERSION
)
1970 pr_debug("RS_VERSION ");
1971 if (status
& RS_STUCKBYPASSS
)
1972 pr_debug("RS_STUCKBYPASSS ");
1973 if (status
& RS_EVENT
)
1974 pr_debug("RS_EVENT ");
1975 if (status
& RS_RINGOPCHANGE
)
1976 pr_debug("RS_RINGOPCHANGE ");
1977 if (status
& RS_RES0
)
1978 pr_debug("RS_RES0 ");
1980 } // ring_status_indication
1983 /************************
1987 * Gets the current time from the system.
1991 * The current time in TICKS_PER_SECOND.
1993 * TICKS_PER_SECOND has the unit 'count of timer ticks per second'. It is
1994 * defined in "targetos.h". The definition of TICKS_PER_SECOND must comply
1995 * to the time returned by smt_get_time().
1997 ************************/
1998 unsigned long smt_get_time(void)
2004 /************************
2008 * Status counter update (ring_op, fifo full).
2010 * smc - A pointer to the SMT context struct.
2012 * stat - = 0: A ring operational change occurred.
2013 * = 1: The FORMAC FIFO buffer is full / FIFO overflow.
2017 ************************/
2018 void smt_stat_counter(struct s_smc
*smc
, int stat
)
2020 // BOOLEAN RingIsUp ;
2022 pr_debug("smt_stat_counter\n");
2025 pr_debug("Ring operational change.\n");
2028 pr_debug("Receive fifo overflow.\n");
2029 smc
->os
.MacStat
.gen
.rx_errors
++;
2032 pr_debug("Unknown status (%d).\n", stat
);
2035 } // smt_stat_counter
2038 /************************
2042 * Sets CFM state in custom statistics.
2044 * smc - A pointer to the SMT context struct.
2046 * c_state - Possible values are:
2048 * EC0_OUT, EC1_IN, EC2_TRACE, EC3_LEAVE, EC4_PATH_TEST,
2049 * EC5_INSERT, EC6_CHECK, EC7_DEINSERT
2053 ************************/
2054 void cfm_state_change(struct s_smc
*smc
, int c_state
)
2082 s
= "SC10_C_WRAP_B";
2085 s
= "SC11_C_WRAP_S";
2088 pr_debug("cfm_state_change: unknown %d\n", c_state
);
2091 pr_debug("cfm_state_change: %s\n", s
);
2092 #endif // DRIVERDEBUG
2093 } // cfm_state_change
2096 /************************
2100 * Sets ECM state in custom statistics.
2102 * smc - A pointer to the SMT context struct.
2104 * e_state - Possible values are:
2106 * SC0_ISOLATED, SC1_WRAP_A (5), SC2_WRAP_B (6), SC4_THRU_A (12),
2107 * SC5_THRU_B (7), SC7_WRAP_S (8)
2111 ************************/
2112 void ecm_state_change(struct s_smc
*smc
, int e_state
)
2131 s
= "EC4_PATH_TEST";
2146 pr_debug("ecm_state_change: %s\n", s
);
2147 #endif //DRIVERDEBUG
2148 } // ecm_state_change
2151 /************************
2155 * Sets RMT state in custom statistics.
2157 * smc - A pointer to the SMT context struct.
2159 * r_state - Possible values are:
2161 * RM0_ISOLATED, RM1_NON_OP, RM2_RING_OP, RM3_DETECT,
2162 * RM4_NON_OP_DUP, RM5_RING_OP_DUP, RM6_DIRECTED, RM7_TRACE
2166 ************************/
2167 void rmt_state_change(struct s_smc
*smc
, int r_state
)
2177 s
= "RM1_NON_OP - not operational";
2180 s
= "RM2_RING_OP - ring operational";
2183 s
= "RM3_DETECT - detect dupl addresses";
2185 case RM4_NON_OP_DUP
:
2186 s
= "RM4_NON_OP_DUP - dupl. addr detected";
2188 case RM5_RING_OP_DUP
:
2189 s
= "RM5_RING_OP_DUP - ring oper. with dupl. addr";
2192 s
= "RM6_DIRECTED - sending directed beacons";
2195 s
= "RM7_TRACE - trace initiated";
2201 pr_debug("[rmt_state_change: %s]\n", s
);
2202 #endif // DRIVERDEBUG
2203 } // rmt_state_change
2206 /************************
2208 * drv_reset_indication
2210 * This function is called by the SMT when it has detected a severe
2211 * hardware problem. The driver should perform a reset on the adapter
2212 * as soon as possible, but not from within this function.
2214 * smc - A pointer to the SMT context struct.
2218 ************************/
2219 void drv_reset_indication(struct s_smc
*smc
)
2221 pr_debug("entering drv_reset_indication\n");
2223 smc
->os
.ResetRequested
= TRUE
; // Set flag.
2225 } // drv_reset_indication
2227 static struct pci_driver skfddi_pci_driver
= {
2229 .id_table
= skfddi_pci_tbl
,
2230 .probe
= skfp_init_one
,
2231 .remove
= skfp_remove_one
,
2234 module_pci_driver(skfddi_pci_driver
);