5 * Copyright Information:
6 * Copyright Digital Equipment Corporation 1996.
8 * This software may be used and distributed according to the terms of
9 * the GNU Public License, incorporated herein by reference.
12 * A Linux device driver supporting the Digital Equipment Corporation
13 * FDDI EISA and PCI controller families. Supported adapters include:
15 * DEC FDDIcontroller/EISA (DEFEA)
16 * DEC FDDIcontroller/PCI (DEFPA)
19 * LVS Lawrence V. Stefani
22 * The author may be reached at:
24 * Inet: stefani@lkg.dec.com
25 * Mail: Digital Equipment Corporation
31 * I'd like to thank Patricia Cross for helping me get started with
32 * Linux, David Davies for a lot of help upgrading and configuring
33 * my development system and for answering many OS and driver
34 * development questions, and Alan Cox for recommendations and
35 * integration help on getting FDDI support into Linux. LVS
37 * Driver Architecture:
38 * The driver architecture is largely based on previous driver work
39 * for other operating systems. The upper edge interface and
40 * functions were largely taken from existing Linux device drivers
41 * such as David Davies' DE4X5.C driver and Donald Becker's TULIP.C
45 * The driver scans for supported EISA adapters by reading the
46 * SLOT ID register for each EISA slot and making a match
47 * against the expected value. The supported PCI adapters are
48 * discovered using successive calls to pcibios_find_device.
49 * The first time the probe routine is called, all supported
50 * devices are discovered and initialized. The adapters aren't
51 * brought up to an operational state until the open routine is
54 * Bus-Specific Initialization -
55 * This driver currently supports both EISA and PCI controller
56 * families. While the custom DMA chip and FDDI logic is similar
57 * or identical, the bus logic is very different. After
58 * initialization, the only bus-specific differences is in how the
59 * driver enables and disables interrupts. Other than that, the
60 * run-time critical code behaves the same on both families.
61 * It's important to note that both adapter families are configured
62 * to I/O map, rather than memory map, the adapter registers.
65 * In the driver open routine, the driver ISR (interrupt service
66 * routine) is registered and the adapter is brought to an
67 * operational state. In the driver close routine, the opposite
68 * occurs; the driver ISR is deregistered and the adapter is
69 * brought to a safe, but closed state. Users may use consecutive
70 * commands to bring the adapter up and down as in the following
77 * Apparently, there is no shutdown or halt routine support under
78 * Linux. This routine would be called during "reboot" or
79 * "shutdown" to allow the driver to place the adapter in a safe
80 * state before a warm reboot occurs. To be really safe, the user
81 * should close the adapter before shutdown (eg. ifconfig fddi0 down)
82 * to ensure that the adapter DMA engine is taken off-line. However,
83 * the current driver code anticipates this problem and always issues
84 * a soft reset of the adapter at the beginning of driver initialization.
85 * A future driver enhancement in this area may occur in 2.1.X where
86 * Alan indicated that a shutdown handler may be implemented.
88 * Interrupt Service Routine -
89 * The driver supports shared interrupts, so the ISR is registered for
90 * each board with the appropriate flag and the pointer to that board's
91 * device structure. This provides the context during interrupt
92 * processing to support shared interrupts and multiple boards.
94 * Interrupt enabling/disabling can occur at many levels. At the host
95 * end, you can disable system interrupts, or disable interrupts at the
96 * PIC (on Intel systems). Across the bus, both EISA and PCI adapters
97 * have a bus-logic chip interrupt enable/disable as well as a DMA
98 * controller interrupt enable/disable.
100 * The driver currently enables and disables adapter interrupts at the
101 * bus-logic chip and assumes that Linux will take care of clearing or
102 * acknowledging any host-based interrupt chips.
104 * Control Functions -
105 * Control functions are those used to support functions such as adding
106 * or deleting multicast addresses, enabling or disabling packet
107 * reception filters, or other custom/proprietary commands. Presently,
108 * the driver supports the "get statistics", "set multicast list", and
109 * "set mac address" functions defined by Linux. A list of possible
110 * enhancements include:
112 * - Custom ioctl interface for executing port interface commands
113 * - Custom ioctl interface for adding unicast addresses to
114 * adapter CAM (to support bridge functions).
115 * - Custom ioctl interface for supporting firmware upgrades.
117 * Hardware (port interface) Support Routines -
118 * The driver function names that start with "dfx_hw_" represent
119 * low-level port interface routines that are called frequently. They
120 * include issuing a DMA or port control command to the adapter,
121 * resetting the adapter, or reading the adapter state. Since the
122 * driver initialization and run-time code must make calls into the
123 * port interface, these routines were written to be as generic and
124 * usable as possible.
127 * The adapter DMA engine supports a 256 entry receive descriptor block
128 * of which up to 255 entries can be used at any given time. The
129 * architecture is a standard producer, consumer, completion model in
130 * which the driver "produces" receive buffers to the adapter, the
131 * adapter "consumes" the receive buffers by DMAing incoming packet data,
132 * and the driver "completes" the receive buffers by servicing the
133 * incoming packet, then "produces" a new buffer and starts the cycle
134 * again. Receive buffers can be fragmented in up to 16 fragments
135 * (descriptor entries). For simplicity, this driver posts
136 * single-fragment receive buffers of 4608 bytes, then allocates a
137 * sk_buff, copies the data, then reposts the buffer. To reduce CPU
138 * utilization, a better approach would be to pass up the receive
139 * buffer (no extra copy) then allocate and post a replacement buffer.
140 * This is a performance enhancement that should be looked into at
144 * Like the receive path, the adapter DMA engine supports a 256 entry
145 * transmit descriptor block of which up to 255 entries can be used at
146 * any given time. Transmit buffers can be fragmented in up to 255
147 * fragments (descriptor entries). This driver always posts one
148 * fragment per transmit packet request.
150 * The fragment contains the entire packet from FC to end of data.
151 * Before posting the buffer to the adapter, the driver sets a three-byte
152 * packet request header (PRH) which is required by the Motorola MAC chip
153 * used on the adapters. The PRH tells the MAC the type of token to
154 * receive/send, whether or not to generate and append the CRC, whether
155 * synchronous or asynchronous framing is used, etc. Since the PRH
156 * definition is not necessarily consistent across all FDDI chipsets,
157 * the driver, rather than the common FDDI packet handler routines,
160 * To reduce the amount of descriptor fetches needed per transmit request,
161 * the driver takes advantage of the fact that there are at least three
162 * bytes available before the skb->data field on the outgoing transmit
163 * request. This is guaranteed by having fddi_setup() in net_init.c set
164 * dev->hard_header_len to 24 bytes. 21 bytes accounts for the largest
165 * header in an 802.2 SNAP frame. The other 3 bytes are the extra "pad"
166 * bytes which we'll use to store the PRH.
168 * There's a subtle advantage to adding these pad bytes to the
169 * hard_header_len, it ensures that the data portion of the packet for
170 * an 802.2 SNAP frame is longword aligned. Other FDDI driver
171 * implementations may not need the extra padding and can start copying
172 * or DMAing directly from the FC byte which starts at skb->data. Should
173 * another driver implementation need ADDITIONAL padding, the net_init.c
174 * module should be updated and dev->hard_header_len should be increased.
175 * NOTE: To maintain the alignment on the data portion of the packet,
176 * dev->hard_header_len should always be evenly divisible by 4 and at
177 * least 24 bytes in size.
179 * Modification History:
180 * Date Name Description
181 * 16-Aug-96 LVS Created.
182 * 20-Aug-96 LVS Updated dfx_probe so that version information
183 * string is only displayed if 1 or more cards are
184 * found. Changed dfx_rcv_queue_process to copy
185 * 3 NULL bytes before FC to ensure that data is
186 * longword aligned in receive buffer.
187 * 09-Sep-96 LVS Updated dfx_ctl_set_multicast_list to enable
188 * LLC group promiscuous mode if multicast list
189 * is too large. LLC individual/group promiscuous
190 * mode is now disabled if IFF_PROMISC flag not set.
191 * dfx_xmt_queue_pkt no longer checks for NULL skb
192 * on Alan Cox recommendation. Added node address
194 * 12-Sep-96 LVS Reset current address to factory address during
195 * device open. Updated transmit path to post a
196 * single fragment which includes PRH->end of data.
199 /* Version information string - should be updated prior to each new release!!! */
201 static const char *version
= "defxx.c:v1.04 09/16/96 Lawrence V. Stefani (stefani@lkg.dec.com)\n";
205 #include <linux/module.h>
207 #include <linux/kernel.h>
208 #include <linux/sched.h>
209 #include <linux/string.h>
210 #include <linux/ptrace.h>
211 #include <linux/errno.h>
212 #include <linux/ioport.h>
213 #include <linux/malloc.h>
214 #include <linux/interrupt.h>
215 #include <linux/pci.h>
216 #include <linux/delay.h>
217 #include <linux/init.h>
218 #include <asm/byteorder.h>
219 #include <asm/bitops.h>
222 #include <linux/netdevice.h>
223 #include <linux/fddidevice.h>
224 #include <linux/skbuff.h>
228 #define DYNAMIC_BUFFERS 1
230 #define SKBUFF_RX_COPYBREAK 200
232 * NEW_SKB_SIZE = PI_RCV_DATA_K_SIZE_MAX+128 to allow 128 byte
233 * alignment for compatibility with old EISA boards.
235 #define NEW_SKB_SIZE (PI_RCV_DATA_K_SIZE_MAX+128)
237 /* Define global routines */
239 int dfx_probe(struct net_device
*dev
);
241 /* Define module-wide (static) routines */
243 static struct net_device
*dfx_alloc_device(struct net_device
*dev
, u16 iobase
);
245 static void dfx_bus_init(struct net_device
*dev
);
246 static void dfx_bus_config_check(DFX_board_t
*bp
);
248 static int dfx_driver_init(struct net_device
*dev
);
249 static int dfx_adap_init(DFX_board_t
*bp
);
251 static int dfx_open(struct net_device
*dev
);
252 static int dfx_close(struct net_device
*dev
);
254 static void dfx_int_pr_halt_id(DFX_board_t
*bp
);
255 static void dfx_int_type_0_process(DFX_board_t
*bp
);
256 static void dfx_int_common(DFX_board_t
*bp
);
257 static void dfx_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
);
259 static struct net_device_stats
*dfx_ctl_get_stats(struct net_device
*dev
);
260 static void dfx_ctl_set_multicast_list(struct net_device
*dev
);
261 static int dfx_ctl_set_mac_address(struct net_device
*dev
, void *addr
);
262 static int dfx_ctl_update_cam(DFX_board_t
*bp
);
263 static int dfx_ctl_update_filters(DFX_board_t
*bp
);
265 static int dfx_hw_dma_cmd_req(DFX_board_t
*bp
);
266 static int dfx_hw_port_ctrl_req(DFX_board_t
*bp
, PI_UINT32 command
, PI_UINT32 data_a
, PI_UINT32 data_b
, PI_UINT32
*host_data
);
267 static void dfx_hw_adap_reset(DFX_board_t
*bp
, PI_UINT32 type
);
268 static int dfx_hw_adap_state_rd(DFX_board_t
*bp
);
269 static int dfx_hw_dma_uninit(DFX_board_t
*bp
, PI_UINT32 type
);
271 static void dfx_rcv_init(DFX_board_t
*bp
);
272 static void dfx_rcv_queue_process(DFX_board_t
*bp
);
274 static int dfx_xmt_queue_pkt(struct sk_buff
*skb
, struct net_device
*dev
);
275 static void dfx_xmt_done(DFX_board_t
*bp
);
276 static void dfx_xmt_flush(DFX_board_t
*bp
);
278 /* Define module-wide (static) variables */
280 static int num_boards
= 0; /* total number of adapters configured */
281 static int already_probed
= 0; /* have we already entered dfx_probe? */
285 * =======================
286 * = dfx_port_write_byte =
287 * = dfx_port_read_byte =
288 * = dfx_port_write_long =
289 * = dfx_port_read_long =
290 * =======================
293 * Routines for reading and writing values from/to adapter
299 * bp - pointer to board information
300 * offset - register offset from base I/O address
301 * data - for dfx_port_write_byte and dfx_port_write_long, this
302 * is a value to write.
303 * for dfx_port_read_byte and dfx_port_read_byte, this
304 * is a pointer to store the read value.
306 * Functional Description:
307 * These routines perform the correct operation to read or write
308 * the adapter register.
310 * EISA port block base addresses are based on the slot number in which the
311 * controller is installed. For example, if the EISA controller is installed
312 * in slot 4, the port block base address is 0x4000. If the controller is
313 * installed in slot 2, the port block base address is 0x2000, and so on.
314 * This port block can be used to access PDQ, ESIC, and DEFEA on-board
315 * registers using the register offsets defined in DEFXX.H.
317 * PCI port block base addresses are assigned by the PCI BIOS or system
318 * firmware. There is one 128 byte port block which can be accessed. It
319 * allows for I/O mapping of both PDQ and PFI registers using the register
320 * offsets defined in DEFXX.H.
326 * bp->base_addr is a valid base I/O address for this adapter.
327 * offset is a valid register offset for this adapter.
330 * Rather than produce macros for these functions, these routines
331 * are defined using "inline" to ensure that the compiler will
332 * generate inline code and not waste a procedure call and return.
333 * This provides all the benefits of macros, but with the
334 * advantage of strict data type checking.
337 static inline void dfx_port_write_byte(
344 u16 port
= bp
->base_addr
+ offset
;
350 static inline void dfx_port_read_byte(
357 u16 port
= bp
->base_addr
+ offset
;
363 static inline void dfx_port_write_long(
370 u16 port
= bp
->base_addr
+ offset
;
376 static inline void dfx_port_read_long(
383 u16 port
= bp
->base_addr
+ offset
;
396 * Probes for supported FDDI EISA and PCI controllers
402 * dev - pointer to device information
404 * Functional Description:
405 * This routine is called by the OS for each FDDI device name (fddi0,
406 * fddi1,...,fddi6, fddi7) specified in drivers/net/Space.c. Since
407 * the DEFXX.C driver currently does not support being loaded as a
408 * module, dfx_probe() will initialize all devices the first time
411 * Let's say that dfx_probe() is getting called to initialize fddi0.
412 * Furthermore, let's say there are three supported controllers in the
413 * system. Before dfx_probe() leaves, devices fddi0, fddi1, and fddi2
414 * will be initialized and a global flag will be set to indicate that
415 * dfx_probe() has already been called.
417 * However...the OS doesn't know that we've already initialized
418 * devices fddi1 and fddi2 so dfx_probe() gets called again and again
419 * until it reaches the end of the device list for FDDI (presently,
420 * fddi7). It's important that the driver "pretend" to probe for
421 * devices fddi1 and fddi2 and return success. Devices fddi3
422 * through fddi7 will return failure since they weren't initialized.
424 * This algorithm seems to work for the time being. As other FDDI
425 * drivers are written for Linux, a more generic approach (perhaps
426 * similar to the Ethernet card approach) may need to be implemented.
429 * 0 - This device (fddi0, fddi1, etc) configured successfully
430 * -ENODEV - No devices present, or no Digital FDDI EISA or PCI device
431 * present for this device name
434 * For the time being, DEFXX.C is the only FDDI driver under Linux.
435 * As this assumption changes, this routine will likely be impacted.
436 * Also, it is assumed that no more than eight (8) FDDI controllers
437 * will be configured in the system (fddi0 through fddi7). This
438 * routine will not allocate new device structures. If more than
439 * eight FDDI controllers need to be configured, drivers/net/Space.c
440 * should be updated as well as the DFX_MAX_NUM_BOARDS constant in
444 * Device structures for FDDI adapters (fddi0, fddi1, etc) are
445 * initialized and the board resources are read and stored in
446 * the device structure.
449 int __init
dfx_probe(struct net_device
*dev
)
451 int i
; /* used in for loops */
452 int version_disp
; /* was version info string already displayed? */
453 int port_len
; /* length of port address range (in bytes) */
454 u16 port
; /* temporary I/O (port) address */
455 struct pci_dev
* pdev
= NULL
; /* PCI device record */
456 u16 command
; /* PCI Configuration space Command register val */
457 u32 slot_id
; /* EISA hardware (slot) ID read from adapter */
458 DFX_board_t
*bp
; /* board pointer */
460 DBG_printk("In dfx_probe...\n");
463 * Verify whether we're going through dfx_probe() again
465 * If so, see if we're going through for a subsequent fddi device that
466 * we've already initialized. If we are, return success (0). If not,
467 * return failure (-ENODEV).
470 version_disp
= 0; /* default to version string not displayed */
473 DBG_printk("Already entered dfx_probe\n");
475 if ((strncmp(dev
->name
, "fddi", 4) == 0) && (dev
->base_addr
!= 0))
477 DBG_printk("In dfx_probe for fddi adapter (%s) we've already initialized it, so return success\n", dev
->name
);
482 already_probed
= 1; /* set global flag */
484 /* Scan for FDDI EISA controllers */
486 for (i
=0; i
< DFX_MAX_EISA_SLOTS
; i
++) /* only scan for up to 16 EISA slots */
488 port
= (i
<< 12) + PI_ESIC_K_SLOT_ID
; /* port = I/O address for reading slot ID */
489 slot_id
= inl(port
); /* read EISA HW (slot) ID */
490 if ((slot_id
& 0xF0FFFFFF) == DEFEA_PRODUCT_ID
)
492 if (!version_disp
) /* display version info if adapter is found */
494 version_disp
= 1; /* set display flag to TRUE so that */
495 printk(version
); /* we only display this string ONCE */
498 port
= (i
<< 12); /* recalc base addr */
500 /* Verify port address range is not already being used */
502 port_len
= PI_ESIC_K_CSR_IO_LEN
;
503 if (check_region(port
, port_len
) == 0)
505 /* Allocate a new device structure for this adapter */
507 dev
= dfx_alloc_device(dev
, port
);
510 /* Initialize board structure with bus-specific info */
512 bp
= (DFX_board_t
*) dev
->priv
;
514 bp
->bus_type
= DFX_BUS_TYPE_EISA
;
515 if (dfx_driver_init(dev
) == DFX_K_SUCCESS
)
516 num_boards
++; /* only increment global board count on success */
518 dev
->base_addr
= 0; /* clear port address field in device structure on failure */
522 printk("I/O range allocated to adapter (0x%X-0x%X) is already being used!\n", port
, (port
+ port_len
-1));
526 /* Scan for FDDI PCI controllers */
528 if (pci_present()) /* is PCI even present? */
529 while ((pdev
= pci_find_device(PCI_VENDOR_ID_DEC
, PCI_DEVICE_ID_DEC_FDDI
, pdev
)))
531 if (!version_disp
) /* display version info if adapter is found */
533 version_disp
= 1; /* set display flag to TRUE so that */
534 printk(version
); /* we only display this string ONCE */
537 /* Verify that I/O enable bit is set (PCI slot is enabled) */
539 pci_read_config_word(pdev
, PCI_COMMAND
, &command
);
540 if ((command
& PCI_COMMAND_IO
) == 0)
541 printk("I/O enable bit not set! Verify that slot is enabled\n");
544 /* Turn off memory mapped space and enable mastering */
546 command
|= PCI_COMMAND_MASTER
;
547 command
&= ~PCI_COMMAND_MEMORY
;
548 pci_write_config_word(pdev
, PCI_COMMAND
, command
);
550 /* Get I/O base address from PCI Configuration Space */
552 port
= pdev
->resource
[1].start
;
554 /* Verify port address range is not already being used */
556 port_len
= PFI_K_CSR_IO_LEN
;
558 if (check_region(port
, port_len
) == 0)
560 /* Allocate a new device structure for this adapter */
562 dev
= dfx_alloc_device(dev
, port
);
565 /* Initialize board structure with bus-specific info */
567 bp
= (DFX_board_t
*) dev
->priv
;
569 bp
->bus_type
= DFX_BUS_TYPE_PCI
;
571 if (dfx_driver_init(dev
) == DFX_K_SUCCESS
)
572 num_boards
++; /* only increment global board count on success */
574 dev
->base_addr
= 0; /* clear port address field in device structure on failure */
578 printk("I/O range allocated to adapter (0x%X-0x%X) is already being used!\n", port
, (port
+ port_len
-1));
583 * If we're at this point we're going through dfx_probe() for the first
584 * time. Return success (0) if we've initialized 1 or more boards.
585 * Otherwise, return failure (-ENODEV).
596 * ====================
597 * = dfx_alloc_device =
598 * ====================
601 * Allocate new device structure for adapter
604 * Pointer to device structure for this adapter or NULL if
605 * none are available or could not allocate memory for
606 * private board structure.
609 * dev - pointer to device information for last device
610 * iobase - base I/O address of new adapter
612 * Functional Description:
613 * The algorithm for allocating a new device structure is
614 * fairly simple. Since we're presently the only FDDI driver
615 * under Linux, we'll find the first device structure with an
616 * "fddi*" device name that's free. If we run out of devices,
617 * we'll fail on error. This is simpler than trying to
618 * allocate the memory for a new device structure, determine
619 * the next free number (beyond 7) and link it into the chain
620 * of devices. A user can always modify drivers/net/Space.c
621 * to add new FDDI device structures if necessary.
623 * Beyond finding a free FDDI device structure, this routine
624 * initializes most of the fields, resource tags, and dispatch
625 * pointers in the device structure and calls the common
626 * fddi_setup() routine to perform the rest of the device
627 * structure initialization.
633 * If additional FDDI drivers are integrated into Linux,
634 * we'll likely need to use a different approach to
635 * allocate a device structure. Perhaps one that is
636 * similar to what the Ethernet drivers use.
642 struct net_device __init
*dfx_alloc_device( struct net_device
*dev
, u16 iobase
)
644 struct net_device
*tmp_dev
; /* pointer to a device structure */
646 DBG_printk("In dfx_alloc_device...\n");
648 /* Find next free fddi entry */
650 for (tmp_dev
= dev
; tmp_dev
!= NULL
; tmp_dev
= tmp_dev
->next
)
651 if ((strncmp(tmp_dev
->name
, "fddi", 4) == 0) && (tmp_dev
->base_addr
== 0))
655 printk("Could not find free FDDI device structure for this adapter!\n");
658 DBG_printk("Device entry free, device name = %s\n", tmp_dev
->name
);
660 /* Allocate space for private board structure */
662 tmp_dev
->priv
= (void *) kmalloc(sizeof(DFX_board_t
), GFP_KERNEL
);
663 if (tmp_dev
->priv
== NULL
)
665 printk("Could not allocate memory for private board structure!\n");
668 memset(tmp_dev
->priv
, 0, sizeof(DFX_board_t
)); /* clear structure */
670 /* Initialize new device structure */
672 tmp_dev
->rmem_end
= 0; /* shared memory isn't used */
673 tmp_dev
->rmem_start
= 0; /* shared memory isn't used */
674 tmp_dev
->mem_end
= 0; /* shared memory isn't used */
675 tmp_dev
->mem_start
= 0; /* shared memory isn't used */
676 tmp_dev
->base_addr
= iobase
; /* save port (I/O) base address */
677 tmp_dev
->irq
= 0; /* set in dfx_bus_init() */
678 tmp_dev
->if_port
= 0; /* not applicable to FDDI adapters */
679 tmp_dev
->dma
= 0; /* Bus Master DMA doesn't require channel */
681 tmp_dev
->get_stats
= &dfx_ctl_get_stats
;
682 tmp_dev
->open
= &dfx_open
;
683 tmp_dev
->stop
= &dfx_close
;
684 tmp_dev
->hard_start_xmit
= &dfx_xmt_queue_pkt
;
685 tmp_dev
->hard_header
= NULL
; /* set in fddi_setup() */
686 tmp_dev
->rebuild_header
= NULL
; /* set in fddi_setup() */
687 tmp_dev
->set_multicast_list
= &dfx_ctl_set_multicast_list
;
688 tmp_dev
->set_mac_address
= &dfx_ctl_set_mac_address
;
689 tmp_dev
->do_ioctl
= NULL
; /* not supported for now &&& */
690 tmp_dev
->set_config
= NULL
; /* not supported for now &&& */
691 tmp_dev
->hard_header_cache
= NULL
; /* not supported */
692 tmp_dev
->header_cache_update
= NULL
; /* not supported */
693 tmp_dev
->change_mtu
= NULL
; /* set in fddi_setup() */
695 /* Initialize remaining device structure information */
708 * Initializes EISA and PCI controller bus-specific logic.
714 * dev - pointer to device information
716 * Functional Description:
717 * Determine and save adapter IRQ in device table,
718 * then perform bus-specific logic initialization.
724 * dev->base_addr has already been set with the proper
725 * base I/O address for this device.
728 * Interrupts are enabled at the adapter bus-specific logic.
729 * Note: Interrupts at the DMA engine (PDQ chip) are not
733 void __init
dfx_bus_init(struct net_device
*dev
)
735 DFX_board_t
*bp
= (DFX_board_t
*)dev
->priv
;
736 u8 val
; /* used for I/O read/writes */
738 DBG_printk("In dfx_bus_init...\n");
741 * Initialize base I/O address field in bp structure
743 * Note: bp->base_addr is the same as dev->base_addr.
744 * It's useful because often we'll need to read
745 * or write registers where we already have the
746 * bp pointer instead of the dev pointer. Having
747 * the base address in the bp structure will
748 * save a pointer dereference.
750 * IMPORTANT!! This field must be defined before
751 * any of the dfx_port_* inline functions are
755 bp
->base_addr
= dev
->base_addr
;
757 /* Initialize adapter based on bus type */
759 if (bp
->bus_type
== DFX_BUS_TYPE_EISA
)
761 /* Get the interrupt level from the ESIC chip */
763 dfx_port_read_byte(bp
, PI_ESIC_K_IO_CONFIG_STAT_0
, &val
);
764 switch ((val
& PI_CONFIG_STAT_0_M_IRQ
) >> PI_CONFIG_STAT_0_V_IRQ
)
766 case PI_CONFIG_STAT_0_IRQ_K_9
:
770 case PI_CONFIG_STAT_0_IRQ_K_10
:
774 case PI_CONFIG_STAT_0_IRQ_K_11
:
778 case PI_CONFIG_STAT_0_IRQ_K_15
:
783 /* Enable access to I/O on the board by writing 0x03 to Function Control Register */
785 dfx_port_write_byte(bp
, PI_ESIC_K_FUNCTION_CNTRL
, PI_ESIC_K_FUNCTION_CNTRL_IO_ENB
);
787 /* Set the I/O decode range of the board */
789 val
= ((dev
->base_addr
>> 12) << PI_IO_CMP_V_SLOT
);
790 dfx_port_write_byte(bp
, PI_ESIC_K_IO_CMP_0_1
, val
);
791 dfx_port_write_byte(bp
, PI_ESIC_K_IO_CMP_1_1
, val
);
793 /* Enable access to rest of module (including PDQ and packet memory) */
795 dfx_port_write_byte(bp
, PI_ESIC_K_SLOT_CNTRL
, PI_SLOT_CNTRL_M_ENB
);
798 * Map PDQ registers into I/O space. This is done by clearing a bit
799 * in Burst Holdoff register.
802 dfx_port_read_byte(bp
, PI_ESIC_K_BURST_HOLDOFF
, &val
);
803 dfx_port_write_byte(bp
, PI_ESIC_K_BURST_HOLDOFF
, (val
& ~PI_BURST_HOLDOFF_M_MEM_MAP
));
805 /* Enable interrupts at EISA bus interface chip (ESIC) */
807 dfx_port_read_byte(bp
, PI_ESIC_K_IO_CONFIG_STAT_0
, &val
);
808 dfx_port_write_byte(bp
, PI_ESIC_K_IO_CONFIG_STAT_0
, (val
| PI_CONFIG_STAT_0_M_INT_ENB
));
812 struct pci_dev
*pdev
= bp
->pci_dev
;
814 /* Get the interrupt level from the PCI Configuration Table */
816 dev
->irq
= pdev
->irq
;
818 /* Check Latency Timer and set if less than minimal */
820 pci_read_config_byte(pdev
, PCI_LATENCY_TIMER
, &val
);
821 if (val
< PFI_K_LAT_TIMER_MIN
) /* if less than min, override with default */
823 val
= PFI_K_LAT_TIMER_DEF
;
824 pci_write_config_byte(pdev
, PCI_LATENCY_TIMER
, val
);
827 /* Enable interrupts at PCI bus interface chip (PFI) */
829 dfx_port_write_long(bp
, PFI_K_REG_MODE_CTRL
, (PFI_MODE_M_PDQ_INT_ENB
| PFI_MODE_M_DMA_ENB
));
836 * ========================
837 * = dfx_bus_config_check =
838 * ========================
841 * Checks the configuration (burst size, full-duplex, etc.) If any parameters
842 * are illegal, then this routine will set new defaults.
848 * bp - pointer to board information
850 * Functional Description:
851 * For Revision 1 FDDI EISA, Revision 2 or later FDDI EISA with rev E or later
852 * PDQ, and all FDDI PCI controllers, all values are legal.
858 * dfx_adap_init has NOT been called yet so burst size and other items have
865 void __init
dfx_bus_config_check(DFX_board_t
*bp
)
867 int status
; /* return code from adapter port control call */
868 u32 slot_id
; /* EISA-bus hardware id (DEC3001, DEC3002,...) */
869 u32 host_data
; /* LW data returned from port control call */
871 DBG_printk("In dfx_bus_config_check...\n");
873 /* Configuration check only valid for EISA adapter */
875 if (bp
->bus_type
== DFX_BUS_TYPE_EISA
)
877 dfx_port_read_long(bp
, PI_ESIC_K_SLOT_ID
, &slot_id
);
880 * First check if revision 2 EISA controller. Rev. 1 cards used
881 * PDQ revision B, so no workaround needed in this case. Rev. 3
882 * cards used PDQ revision E, so no workaround needed in this
883 * case, either. Only Rev. 2 cards used either Rev. D or E
884 * chips, so we must verify the chip revision on Rev. 2 cards.
887 if (slot_id
== DEFEA_PROD_ID_2
)
890 * Revision 2 FDDI EISA controller found, so let's check PDQ
891 * revision of adapter.
894 status
= dfx_hw_port_ctrl_req(bp
,
896 PI_SUB_CMD_K_PDQ_REV_GET
,
899 if ((status
!= DFX_K_SUCCESS
) || (host_data
== 2))
902 * Either we couldn't determine the PDQ revision, or
903 * we determined that it is at revision D. In either case,
904 * we need to implement the workaround.
907 /* Ensure that the burst size is set to 8 longwords or less */
909 switch (bp
->burst_size
)
911 case PI_PDATA_B_DMA_BURST_SIZE_32
:
912 case PI_PDATA_B_DMA_BURST_SIZE_16
:
913 bp
->burst_size
= PI_PDATA_B_DMA_BURST_SIZE_8
;
920 /* Ensure that full-duplex mode is not enabled */
922 bp
->full_duplex_enb
= PI_SNMP_K_FALSE
;
931 * ===================
932 * = dfx_driver_init =
933 * ===================
936 * Initializes remaining adapter board structure information
937 * and makes sure adapter is in a safe state prior to dfx_open().
943 * dev - pointer to device information
945 * Functional Description:
946 * This function allocates additional resources such as the host memory
947 * blocks needed by the adapter (eg. descriptor and consumer blocks).
948 * Remaining bus initialization steps are also completed. The adapter
949 * is also reset so that it is in the DMA_UNAVAILABLE state. The OS
950 * must call dfx_open() to open the adapter and bring it on-line.
953 * DFX_K_SUCCESS - initialization succeeded
954 * DFX_K_FAILURE - initialization failed - could not allocate memory
955 * or read adapter MAC address
958 * Memory allocated from kmalloc() call is physically contiguous, locked
959 * memory whose physical address equals its virtual address.
962 * Adapter is reset and should be in DMA_UNAVAILABLE state before
963 * returning from this routine.
966 int __init
dfx_driver_init(struct net_device
*dev
)
968 DFX_board_t
*bp
= (DFX_board_t
*)dev
->priv
;
969 int alloc_size
; /* total buffer size needed */
970 char *top_v
, *curr_v
; /* virtual addrs into memory block */
971 u32 top_p
, curr_p
; /* physical addrs into memory block */
972 u32 data
; /* host data register value */
974 DBG_printk("In dfx_driver_init...\n");
976 /* Initialize bus-specific hardware registers */
981 * Initialize default values for configurable parameters
983 * Note: All of these parameters are ones that a user may
984 * want to customize. It'd be nice to break these
985 * out into Space.c or someplace else that's more
986 * accessible/understandable than this file.
989 bp
->full_duplex_enb
= PI_SNMP_K_FALSE
;
990 bp
->req_ttrt
= 8 * 12500; /* 8ms in 80 nanosec units */
991 bp
->burst_size
= PI_PDATA_B_DMA_BURST_SIZE_DEF
;
992 bp
->rcv_bufs_to_post
= RCV_BUFS_DEF
;
995 * Ensure that HW configuration is OK
997 * Note: Depending on the hardware revision, we may need to modify
998 * some of the configurable parameters to workaround hardware
999 * limitations. We'll perform this configuration check AFTER
1000 * setting the parameters to their default values.
1003 dfx_bus_config_check(bp
);
1005 /* Disable PDQ interrupts first */
1007 dfx_port_write_long(bp
, PI_PDQ_K_REG_HOST_INT_ENB
, PI_HOST_INT_K_DISABLE_ALL_INTS
);
1009 /* Place adapter in DMA_UNAVAILABLE state by resetting adapter */
1011 (void) dfx_hw_dma_uninit(bp
, PI_PDATA_A_RESET_M_SKIP_ST
);
1013 /* Read the factory MAC address from the adapter then save it */
1015 if (dfx_hw_port_ctrl_req(bp
,
1017 PI_PDATA_A_MLA_K_LO
,
1019 &data
) != DFX_K_SUCCESS
)
1021 printk("%s: Could not read adapter factory MAC address!\n", dev
->name
);
1022 return(DFX_K_FAILURE
);
1024 memcpy(&bp
->factory_mac_addr
[0], &data
, sizeof(u32
));
1026 if (dfx_hw_port_ctrl_req(bp
,
1028 PI_PDATA_A_MLA_K_HI
,
1030 &data
) != DFX_K_SUCCESS
)
1032 printk("%s: Could not read adapter factory MAC address!\n", dev
->name
);
1033 return(DFX_K_FAILURE
);
1035 memcpy(&bp
->factory_mac_addr
[4], &data
, sizeof(u16
));
1038 * Set current address to factory address
1040 * Note: Node address override support is handled through
1041 * dfx_ctl_set_mac_address.
1044 memcpy(dev
->dev_addr
, bp
->factory_mac_addr
, FDDI_K_ALEN
);
1045 if (bp
->bus_type
== DFX_BUS_TYPE_EISA
)
1046 printk("%s: DEFEA at I/O addr = 0x%lX, IRQ = %d, Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n",
1057 printk("%s: DEFPA at I/O addr = 0x%lX, IRQ = %d, Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n",
1069 * Get memory for descriptor block, consumer block, and other buffers
1070 * that need to be DMA read or written to by the adapter.
1073 alloc_size
= sizeof(PI_DESCR_BLOCK
) +
1074 PI_CMD_REQ_K_SIZE_MAX
+
1075 PI_CMD_RSP_K_SIZE_MAX
+
1076 #ifndef DYNAMIC_BUFFERS
1077 (bp
->rcv_bufs_to_post
* PI_RCV_DATA_K_SIZE_MAX
) +
1079 sizeof(PI_CONSUMER_BLOCK
) +
1080 (PI_ALIGN_K_DESC_BLK
- 1);
1081 top_v
= (char *) kmalloc(alloc_size
, GFP_KERNEL
);
1084 printk("%s: Could not allocate memory for host buffers and structures!\n", dev
->name
);
1085 return(DFX_K_FAILURE
);
1087 memset(top_v
, 0, alloc_size
); /* zero out memory before continuing */
1088 top_p
= virt_to_bus(top_v
); /* get physical address of buffer */
1091 * To guarantee the 8K alignment required for the descriptor block, 8K - 1
1092 * plus the amount of memory needed was allocated. The physical address
1093 * is now 8K aligned. By carving up the memory in a specific order,
1094 * we'll guarantee the alignment requirements for all other structures.
1096 * Note: If the assumptions change regarding the non-paged, non-cached,
1097 * physically contiguous nature of the memory block or the address
1098 * alignments, then we'll need to implement a different algorithm
1099 * for allocating the needed memory.
1102 curr_p
= (u32
) (ALIGN(top_p
, PI_ALIGN_K_DESC_BLK
));
1103 curr_v
= top_v
+ (curr_p
- top_p
);
1105 /* Reserve space for descriptor block */
1107 bp
->descr_block_virt
= (PI_DESCR_BLOCK
*) curr_v
;
1108 bp
->descr_block_phys
= curr_p
;
1109 curr_v
+= sizeof(PI_DESCR_BLOCK
);
1110 curr_p
+= sizeof(PI_DESCR_BLOCK
);
1112 /* Reserve space for command request buffer */
1114 bp
->cmd_req_virt
= (PI_DMA_CMD_REQ
*) curr_v
;
1115 bp
->cmd_req_phys
= curr_p
;
1116 curr_v
+= PI_CMD_REQ_K_SIZE_MAX
;
1117 curr_p
+= PI_CMD_REQ_K_SIZE_MAX
;
1119 /* Reserve space for command response buffer */
1121 bp
->cmd_rsp_virt
= (PI_DMA_CMD_RSP
*) curr_v
;
1122 bp
->cmd_rsp_phys
= curr_p
;
1123 curr_v
+= PI_CMD_RSP_K_SIZE_MAX
;
1124 curr_p
+= PI_CMD_RSP_K_SIZE_MAX
;
1126 /* Reserve space for the LLC host receive queue buffers */
1128 bp
->rcv_block_virt
= curr_v
;
1129 bp
->rcv_block_phys
= curr_p
;
1131 #ifndef DYNAMIC_BUFFERS
1132 curr_v
+= (bp
->rcv_bufs_to_post
* PI_RCV_DATA_K_SIZE_MAX
);
1133 curr_p
+= (bp
->rcv_bufs_to_post
* PI_RCV_DATA_K_SIZE_MAX
);
1136 /* Reserve space for the consumer block */
1138 bp
->cons_block_virt
= (PI_CONSUMER_BLOCK
*) curr_v
;
1139 bp
->cons_block_phys
= curr_p
;
1141 /* Display virtual and physical addresses if debug driver */
1143 DBG_printk("%s: Descriptor block virt = %0lX, phys = %0X\n", dev
->name
, (long)bp
->descr_block_virt
, bp
->descr_block_phys
);
1144 DBG_printk("%s: Command Request buffer virt = %0lX, phys = %0X\n", dev
->name
, (long)bp
->cmd_req_virt
, bp
->cmd_req_phys
);
1145 DBG_printk("%s: Command Response buffer virt = %0lX, phys = %0X\n", dev
->name
, (long)bp
->cmd_rsp_virt
, bp
->cmd_rsp_phys
);
1146 DBG_printk("%s: Receive buffer block virt = %0lX, phys = %0X\n", dev
->name
, (long)bp
->rcv_block_virt
, bp
->rcv_block_phys
);
1147 DBG_printk("%s: Consumer block virt = %0lX, phys = %0X\n", dev
->name
, (long)bp
->cons_block_virt
, bp
->cons_block_phys
);
1149 return(DFX_K_SUCCESS
);
1159 * Brings the adapter to the link avail/link unavailable state.
1165 * bp - pointer to board information
1167 * Functional Description:
1168 * Issues the low-level firmware/hardware calls necessary to bring
1169 * the adapter up, or to properly reset and restore adapter during
1173 * DFX_K_SUCCESS - Adapter brought up successfully
1174 * DFX_K_FAILURE - Adapter initialization failed
1177 * bp->reset_type should be set to a valid reset type value before
1178 * calling this routine.
1181 * Adapter should be in LINK_AVAILABLE or LINK_UNAVAILABLE state
1182 * upon a successful return of this routine.
1190 DBG_printk("In dfx_adap_init...\n");
1192 /* Disable PDQ interrupts first */
1194 dfx_port_write_long(bp
, PI_PDQ_K_REG_HOST_INT_ENB
, PI_HOST_INT_K_DISABLE_ALL_INTS
);
1196 /* Place adapter in DMA_UNAVAILABLE state by resetting adapter */
1198 if (dfx_hw_dma_uninit(bp
, bp
->reset_type
) != DFX_K_SUCCESS
)
1200 printk("%s: Could not uninitialize/reset adapter!\n", bp
->dev
->name
);
1201 return(DFX_K_FAILURE
);
1205 * When the PDQ is reset, some false Type 0 interrupts may be pending,
1206 * so we'll acknowledge all Type 0 interrupts now before continuing.
1209 dfx_port_write_long(bp
, PI_PDQ_K_REG_TYPE_0_STATUS
, PI_HOST_INT_K_ACK_ALL_TYPE_0
);
1212 * Clear Type 1 and Type 2 registers before going to DMA_AVAILABLE state
1214 * Note: We only need to clear host copies of these registers. The PDQ reset
1215 * takes care of the on-board register values.
1218 bp
->cmd_req_reg
.lword
= 0;
1219 bp
->cmd_rsp_reg
.lword
= 0;
1220 bp
->rcv_xmt_reg
.lword
= 0;
1222 /* Clear consumer block before going to DMA_AVAILABLE state */
1224 memset(bp
->cons_block_virt
, 0, sizeof(PI_CONSUMER_BLOCK
));
1226 /* Initialize the DMA Burst Size */
1228 if (dfx_hw_port_ctrl_req(bp
,
1230 PI_SUB_CMD_K_BURST_SIZE_SET
,
1232 NULL
) != DFX_K_SUCCESS
)
1234 printk("%s: Could not set adapter burst size!\n", bp
->dev
->name
);
1235 return(DFX_K_FAILURE
);
1239 * Set base address of Consumer Block
1241 * Assumption: 32-bit physical address of consumer block is 64 byte
1242 * aligned. That is, bits 0-5 of the address must be zero.
1245 if (dfx_hw_port_ctrl_req(bp
,
1246 PI_PCTRL_M_CONS_BLOCK
,
1247 bp
->cons_block_phys
,
1249 NULL
) != DFX_K_SUCCESS
)
1251 printk("%s: Could not set consumer block address!\n", bp
->dev
->name
);
1252 return(DFX_K_FAILURE
);
1256 * Set base address of Descriptor Block and bring adapter to DMA_AVAILABLE state
1258 * Note: We also set the literal and data swapping requirements in this
1259 * command. Since this driver presently runs on Intel platforms
1260 * which are Little Endian, we'll tell the adapter to byte swap
1261 * data only. This code will need to change when we support
1262 * Big Endian systems (eg. PowerPC).
1264 * Assumption: 32-bit physical address of descriptor block is 8Kbyte
1265 * aligned. That is, bits 0-12 of the address must be zero.
1268 if (dfx_hw_port_ctrl_req(bp
,
1270 (u32
) (bp
->descr_block_phys
| PI_PDATA_A_INIT_M_BSWAP_DATA
),
1272 NULL
) != DFX_K_SUCCESS
)
1274 printk("%s: Could not set descriptor block address!\n", bp
->dev
->name
);
1275 return(DFX_K_FAILURE
);
1278 /* Set transmit flush timeout value */
1280 bp
->cmd_req_virt
->cmd_type
= PI_CMD_K_CHARS_SET
;
1281 bp
->cmd_req_virt
->char_set
.item
[0].item_code
= PI_ITEM_K_FLUSH_TIME
;
1282 bp
->cmd_req_virt
->char_set
.item
[0].value
= 3; /* 3 seconds */
1283 bp
->cmd_req_virt
->char_set
.item
[0].item_index
= 0;
1284 bp
->cmd_req_virt
->char_set
.item
[1].item_code
= PI_ITEM_K_EOL
;
1285 if (dfx_hw_dma_cmd_req(bp
) != DFX_K_SUCCESS
)
1287 printk("%s: DMA command request failed!\n", bp
->dev
->name
);
1288 return(DFX_K_FAILURE
);
1291 /* Set the initial values for eFDXEnable and MACTReq MIB objects */
1293 bp
->cmd_req_virt
->cmd_type
= PI_CMD_K_SNMP_SET
;
1294 bp
->cmd_req_virt
->snmp_set
.item
[0].item_code
= PI_ITEM_K_FDX_ENB_DIS
;
1295 bp
->cmd_req_virt
->snmp_set
.item
[0].value
= bp
->full_duplex_enb
;
1296 bp
->cmd_req_virt
->snmp_set
.item
[0].item_index
= 0;
1297 bp
->cmd_req_virt
->snmp_set
.item
[1].item_code
= PI_ITEM_K_MAC_T_REQ
;
1298 bp
->cmd_req_virt
->snmp_set
.item
[1].value
= bp
->req_ttrt
;
1299 bp
->cmd_req_virt
->snmp_set
.item
[1].item_index
= 0;
1300 bp
->cmd_req_virt
->snmp_set
.item
[2].item_code
= PI_ITEM_K_EOL
;
1301 if (dfx_hw_dma_cmd_req(bp
) != DFX_K_SUCCESS
)
1303 printk("%s: DMA command request failed!\n", bp
->dev
->name
);
1304 return(DFX_K_FAILURE
);
1307 /* Initialize adapter CAM */
1309 if (dfx_ctl_update_cam(bp
) != DFX_K_SUCCESS
)
1311 printk("%s: Adapter CAM update failed!\n", bp
->dev
->name
);
1312 return(DFX_K_FAILURE
);
1315 /* Initialize adapter filters */
1317 if (dfx_ctl_update_filters(bp
) != DFX_K_SUCCESS
)
1319 printk("%s: Adapter filters update failed!\n", bp
->dev
->name
);
1320 return(DFX_K_FAILURE
);
1323 /* Initialize receive descriptor block and produce buffers */
1327 /* Issue START command and bring adapter to LINK_(UN)AVAILABLE state */
1329 bp
->cmd_req_virt
->cmd_type
= PI_CMD_K_START
;
1330 if (dfx_hw_dma_cmd_req(bp
) != DFX_K_SUCCESS
)
1332 printk("%s: Start command failed\n", bp
->dev
->name
);
1333 return(DFX_K_FAILURE
);
1336 /* Initialization succeeded, reenable PDQ interrupts */
1338 dfx_port_write_long(bp
, PI_PDQ_K_REG_HOST_INT_ENB
, PI_HOST_INT_K_ENABLE_DEF_INTS
);
1339 return(DFX_K_SUCCESS
);
1355 * dev - pointer to device information
1357 * Functional Description:
1358 * This function brings the adapter to an operational state.
1361 * 0 - Adapter was successfully opened
1362 * -EAGAIN - Could not register IRQ or adapter initialization failed
1365 * This routine should only be called for a device that was
1366 * initialized successfully during the dfx_probe process.
1369 * Adapter should be in LINK_AVAILABLE or LINK_UNAVAILABLE state
1370 * if the open is successful.
1374 struct net_device
*dev
1378 DFX_board_t
*bp
= (DFX_board_t
*)dev
->priv
;
1380 DBG_printk("In dfx_open...\n");
1382 /* Register IRQ - support shared interrupts by passing device ptr */
1384 if (request_irq(dev
->irq
, (void *)dfx_interrupt
, SA_SHIRQ
, dev
->name
, dev
))
1386 printk("%s: Requested IRQ %d is busy\n", dev
->name
, dev
->irq
);
1391 * Set current address to factory MAC address
1393 * Note: We've already done this step in dfx_driver_init.
1394 * However, it's possible that a user has set a node
1395 * address override, then closed and reopened the
1396 * adapter. Unless we reset the device address field
1397 * now, we'll continue to use the existing modified
1401 memcpy(dev
->dev_addr
, bp
->factory_mac_addr
, FDDI_K_ALEN
);
1403 /* Clear local unicast/multicast address tables and counts */
1405 memset(bp
->uc_table
, 0, sizeof(bp
->uc_table
));
1406 memset(bp
->mc_table
, 0, sizeof(bp
->mc_table
));
1410 /* Disable promiscuous filter settings */
1412 bp
->ind_group_prom
= PI_FSTATE_K_BLOCK
;
1413 bp
->group_prom
= PI_FSTATE_K_BLOCK
;
1415 /* Reset and initialize adapter */
1417 bp
->reset_type
= PI_PDATA_A_RESET_M_SKIP_ST
; /* skip self-test */
1418 if (dfx_adap_init(bp
) != DFX_K_SUCCESS
)
1420 printk("%s: Adapter open failed!\n", dev
->name
);
1424 /* Set device structure info */
1427 dev
->interrupt
= DFX_UNMASK_INTERRUPTS
;
1439 * Closes the device/module.
1445 * dev - pointer to device information
1447 * Functional Description:
1448 * This routine closes the adapter and brings it to a safe state.
1449 * The interrupt service routine is deregistered with the OS.
1450 * The adapter can be opened again with another call to dfx_open().
1456 * No further requests for this adapter are made after this routine is
1457 * called. dfx_open() can be called to reset and reinitialize the
1461 * Adapter should be in DMA_UNAVAILABLE state upon completion of this
1466 struct net_device
*dev
1470 DFX_board_t
*bp
= (DFX_board_t
*)dev
->priv
;
1472 DBG_printk("In dfx_close...\n");
1474 /* Disable PDQ interrupts first */
1476 dfx_port_write_long(bp
, PI_PDQ_K_REG_HOST_INT_ENB
, PI_HOST_INT_K_DISABLE_ALL_INTS
);
1478 /* Place adapter in DMA_UNAVAILABLE state by resetting adapter */
1480 (void) dfx_hw_dma_uninit(bp
, PI_PDATA_A_RESET_M_SKIP_ST
);
1483 * Flush any pending transmit buffers
1485 * Note: It's important that we flush the transmit buffers
1486 * BEFORE we clear our copy of the Type 2 register.
1487 * Otherwise, we'll have no idea how many buffers
1494 * Clear Type 1 and Type 2 registers after adapter reset
1496 * Note: Even though we're closing the adapter, it's
1497 * possible that an interrupt will occur after
1498 * dfx_close is called. Without some assurance to
1499 * the contrary we want to make sure that we don't
1500 * process receive and transmit LLC frames and update
1501 * the Type 2 register with bad information.
1504 bp
->cmd_req_reg
.lword
= 0;
1505 bp
->cmd_rsp_reg
.lword
= 0;
1506 bp
->rcv_xmt_reg
.lword
= 0;
1508 /* Clear consumer block for the same reason given above */
1510 memset(bp
->cons_block_virt
, 0, sizeof(PI_CONSUMER_BLOCK
));
1512 /* Clear device structure flags */
1517 /* Deregister (free) IRQ */
1519 free_irq(dev
->irq
, dev
);
1525 * ======================
1526 * = dfx_int_pr_halt_id =
1527 * ======================
1530 * Displays halt id's in string form.
1536 * bp - pointer to board information
1538 * Functional Description:
1539 * Determine current halt id and display appropriate string.
1551 void dfx_int_pr_halt_id(
1556 PI_UINT32 port_status
; /* PDQ port status register value */
1557 PI_UINT32 halt_id
; /* PDQ port status halt ID */
1559 /* Read the latest port status */
1561 dfx_port_read_long(bp
, PI_PDQ_K_REG_PORT_STATUS
, &port_status
);
1563 /* Display halt state transition information */
1565 halt_id
= (port_status
& PI_PSTATUS_M_HALT_ID
) >> PI_PSTATUS_V_HALT_ID
;
1568 case PI_HALT_ID_K_SELFTEST_TIMEOUT
:
1569 printk("%s: Halt ID: Selftest Timeout\n", bp
->dev
->name
);
1572 case PI_HALT_ID_K_PARITY_ERROR
:
1573 printk("%s: Halt ID: Host Bus Parity Error\n", bp
->dev
->name
);
1576 case PI_HALT_ID_K_HOST_DIR_HALT
:
1577 printk("%s: Halt ID: Host-Directed Halt\n", bp
->dev
->name
);
1580 case PI_HALT_ID_K_SW_FAULT
:
1581 printk("%s: Halt ID: Adapter Software Fault\n", bp
->dev
->name
);
1584 case PI_HALT_ID_K_HW_FAULT
:
1585 printk("%s: Halt ID: Adapter Hardware Fault\n", bp
->dev
->name
);
1588 case PI_HALT_ID_K_PC_TRACE
:
1589 printk("%s: Halt ID: FDDI Network PC Trace Path Test\n", bp
->dev
->name
);
1592 case PI_HALT_ID_K_DMA_ERROR
:
1593 printk("%s: Halt ID: Adapter DMA Error\n", bp
->dev
->name
);
1596 case PI_HALT_ID_K_IMAGE_CRC_ERROR
:
1597 printk("%s: Halt ID: Firmware Image CRC Error\n", bp
->dev
->name
);
1600 case PI_HALT_ID_K_BUS_EXCEPTION
:
1601 printk("%s: Halt ID: 68000 Bus Exception\n", bp
->dev
->name
);
1605 printk("%s: Halt ID: Unknown (code = %X)\n", bp
->dev
->name
, halt_id
);
1613 * ==========================
1614 * = dfx_int_type_0_process =
1615 * ==========================
1618 * Processes Type 0 interrupts.
1624 * bp - pointer to board information
1626 * Functional Description:
1627 * Processes all enabled Type 0 interrupts. If the reason for the interrupt
1628 * is a serious fault on the adapter, then an error message is displayed
1629 * and the adapter is reset.
1631 * One tricky potential timing window is the rapid succession of "link avail"
1632 * "link unavail" state change interrupts. The acknowledgement of the Type 0
1633 * interrupt must be done before reading the state from the Port Status
1634 * register. This is true because a state change could occur after reading
1635 * the data, but before acknowledging the interrupt. If this state change
1636 * does happen, it would be lost because the driver is using the old state,
1637 * and it will never know about the new state because it subsequently
1638 * acknowledges the state change interrupt.
1641 * read type 0 int reasons read type 0 int reasons
1642 * read adapter state ack type 0 interrupts
1643 * ack type 0 interrupts read adapter state
1644 * ... process interrupt ... ... process interrupt ...
1653 * An adapter reset may occur if the adapter has any Type 0 error interrupts
1654 * or if the port status indicates that the adapter is halted. The driver
1655 * is responsible for reinitializing the adapter with the current CAM
1656 * contents and adapter filter settings.
1659 void dfx_int_type_0_process(
1664 PI_UINT32 type_0_status
; /* Host Interrupt Type 0 register */
1665 PI_UINT32 state
; /* current adap state (from port status) */
1668 * Read host interrupt Type 0 register to determine which Type 0
1669 * interrupts are pending. Immediately write it back out to clear
1673 dfx_port_read_long(bp
, PI_PDQ_K_REG_TYPE_0_STATUS
, &type_0_status
);
1674 dfx_port_write_long(bp
, PI_PDQ_K_REG_TYPE_0_STATUS
, type_0_status
);
1676 /* Check for Type 0 error interrupts */
1678 if (type_0_status
& (PI_TYPE_0_STAT_M_NXM
|
1679 PI_TYPE_0_STAT_M_PM_PAR_ERR
|
1680 PI_TYPE_0_STAT_M_BUS_PAR_ERR
))
1682 /* Check for Non-Existent Memory error */
1684 if (type_0_status
& PI_TYPE_0_STAT_M_NXM
)
1685 printk("%s: Non-Existent Memory Access Error\n", bp
->dev
->name
);
1687 /* Check for Packet Memory Parity error */
1689 if (type_0_status
& PI_TYPE_0_STAT_M_PM_PAR_ERR
)
1690 printk("%s: Packet Memory Parity Error\n", bp
->dev
->name
);
1692 /* Check for Host Bus Parity error */
1694 if (type_0_status
& PI_TYPE_0_STAT_M_BUS_PAR_ERR
)
1695 printk("%s: Host Bus Parity Error\n", bp
->dev
->name
);
1697 /* Reset adapter and bring it back on-line */
1699 bp
->link_available
= PI_K_FALSE
; /* link is no longer available */
1700 bp
->reset_type
= 0; /* rerun on-board diagnostics */
1701 printk("%s: Resetting adapter...\n", bp
->dev
->name
);
1702 if (dfx_adap_init(bp
) != DFX_K_SUCCESS
)
1704 printk("%s: Adapter reset failed! Disabling adapter interrupts.\n", bp
->dev
->name
);
1705 dfx_port_write_long(bp
, PI_PDQ_K_REG_HOST_INT_ENB
, PI_HOST_INT_K_DISABLE_ALL_INTS
);
1708 printk("%s: Adapter reset successful!\n", bp
->dev
->name
);
1712 /* Check for transmit flush interrupt */
1714 if (type_0_status
& PI_TYPE_0_STAT_M_XMT_FLUSH
)
1716 /* Flush any pending xmt's and acknowledge the flush interrupt */
1718 bp
->link_available
= PI_K_FALSE
; /* link is no longer available */
1719 dfx_xmt_flush(bp
); /* flush any outstanding packets */
1720 (void) dfx_hw_port_ctrl_req(bp
,
1721 PI_PCTRL_M_XMT_DATA_FLUSH_DONE
,
1727 /* Check for adapter state change */
1729 if (type_0_status
& PI_TYPE_0_STAT_M_STATE_CHANGE
)
1731 /* Get latest adapter state */
1733 state
= dfx_hw_adap_state_rd(bp
); /* get adapter state */
1734 if (state
== PI_STATE_K_HALTED
)
1737 * Adapter has transitioned to HALTED state, try to reset
1738 * adapter to bring it back on-line. If reset fails,
1739 * leave the adapter in the broken state.
1742 printk("%s: Controller has transitioned to HALTED state!\n", bp
->dev
->name
);
1743 dfx_int_pr_halt_id(bp
); /* display halt id as string */
1745 /* Reset adapter and bring it back on-line */
1747 bp
->link_available
= PI_K_FALSE
; /* link is no longer available */
1748 bp
->reset_type
= 0; /* rerun on-board diagnostics */
1749 printk("%s: Resetting adapter...\n", bp
->dev
->name
);
1750 if (dfx_adap_init(bp
) != DFX_K_SUCCESS
)
1752 printk("%s: Adapter reset failed! Disabling adapter interrupts.\n", bp
->dev
->name
);
1753 dfx_port_write_long(bp
, PI_PDQ_K_REG_HOST_INT_ENB
, PI_HOST_INT_K_DISABLE_ALL_INTS
);
1756 printk("%s: Adapter reset successful!\n", bp
->dev
->name
);
1758 else if (state
== PI_STATE_K_LINK_AVAIL
)
1760 bp
->link_available
= PI_K_TRUE
; /* set link available flag */
1768 * ==================
1769 * = dfx_int_common =
1770 * ==================
1773 * Interrupt service routine (ISR)
1779 * bp - pointer to board information
1781 * Functional Description:
1782 * This is the ISR which processes incoming adapter interrupts.
1788 * This routine assumes PDQ interrupts have not been disabled.
1789 * When interrupts are disabled at the PDQ, the Port Status register
1790 * is automatically cleared. This routine uses the Port Status
1791 * register value to determine whether a Type 0 interrupt occurred,
1792 * so it's important that adapter interrupts are not normally
1793 * enabled/disabled at the PDQ.
1795 * It's vital that this routine is NOT reentered for the
1796 * same board and that the OS is not in another section of
1797 * code (eg. dfx_xmt_queue_pkt) for the same board on a
1801 * Pending interrupts are serviced. Depending on the type of
1802 * interrupt, acknowledging and clearing the interrupt at the
1803 * PDQ involves writing a register to clear the interrupt bit
1804 * or updating completion indices.
1807 void dfx_int_common(
1812 PI_UINT32 port_status
; /* Port Status register */
1814 /* Process xmt interrupts - frequent case, so always call this routine */
1816 dfx_xmt_done(bp
); /* free consumed xmt packets */
1818 /* Process rcv interrupts - frequent case, so always call this routine */
1820 dfx_rcv_queue_process(bp
); /* service received LLC frames */
1823 * Transmit and receive producer and completion indices are updated on the
1824 * adapter by writing to the Type 2 Producer register. Since the frequent
1825 * case is that we'll be processing either LLC transmit or receive buffers,
1826 * we'll optimize I/O writes by doing a single register write here.
1829 dfx_port_write_long(bp
, PI_PDQ_K_REG_TYPE_2_PROD
, bp
->rcv_xmt_reg
.lword
);
1831 /* Read PDQ Port Status register to find out which interrupts need processing */
1833 dfx_port_read_long(bp
, PI_PDQ_K_REG_PORT_STATUS
, &port_status
);
1835 /* Process Type 0 interrupts (if any) - infrequent, so only call when needed */
1837 if (port_status
& PI_PSTATUS_M_TYPE_0_PENDING
)
1838 dfx_int_type_0_process(bp
); /* process Type 0 interrupts */
1849 * Interrupt processing routine
1855 * irq - interrupt vector
1856 * dev_id - pointer to device information
1857 * regs - pointer to registers structure
1859 * Functional Description:
1860 * This routine calls the interrupt processing routine for this adapter. It
1861 * disables and reenables adapter interrupts, as appropriate. We can support
1862 * shared interrupts since the incoming dev_id pointer provides our device
1863 * structure context.
1869 * The interrupt acknowledgement at the hardware level (eg. ACKing the PIC
1870 * on Intel-based systems) is done by the operating system outside this
1873 * System interrupts are enabled through this call.
1876 * Interrupts are disabled, then reenabled at the adapter.
1882 struct pt_regs
*regs
1886 struct net_device
*dev
= (struct net_device
*) dev_id
;
1887 DFX_board_t
*bp
; /* private board structure pointer */
1888 u8 tmp
; /* used for disabling/enabling ints */
1890 /* Get board pointer only if device structure is valid */
1894 printk("dfx_interrupt(): irq %d for unknown device!\n", irq
);
1897 bp
= (DFX_board_t
*) dev
->priv
;
1899 spin_lock(&bp
->lock
);
1901 /* See if we're already servicing an interrupt */
1904 printk("%s: Re-entering the interrupt handler!\n", dev
->name
);
1905 dev
->interrupt
= DFX_MASK_INTERRUPTS
; /* ensure non reentrancy */
1907 /* Service adapter interrupts */
1909 if (bp
->bus_type
== DFX_BUS_TYPE_PCI
)
1911 /* Disable PDQ-PFI interrupts at PFI */
1913 dfx_port_write_long(bp
, PFI_K_REG_MODE_CTRL
, PFI_MODE_M_DMA_ENB
);
1915 /* Call interrupt service routine for this adapter */
1919 /* Clear PDQ interrupt status bit and reenable interrupts */
1921 dfx_port_write_long(bp
, PFI_K_REG_STATUS
, PFI_STATUS_M_PDQ_INT
);
1922 dfx_port_write_long(bp
, PFI_K_REG_MODE_CTRL
,
1923 (PFI_MODE_M_PDQ_INT_ENB
+ PFI_MODE_M_DMA_ENB
));
1927 /* Disable interrupts at the ESIC */
1929 dfx_port_read_byte(bp
, PI_ESIC_K_IO_CONFIG_STAT_0
, &tmp
);
1930 tmp
&= ~PI_CONFIG_STAT_0_M_INT_ENB
;
1931 dfx_port_write_byte(bp
, PI_ESIC_K_IO_CONFIG_STAT_0
, tmp
);
1933 /* Call interrupt service routine for this adapter */
1937 /* Reenable interrupts at the ESIC */
1939 dfx_port_read_byte(bp
, PI_ESIC_K_IO_CONFIG_STAT_0
, &tmp
);
1940 tmp
|= PI_CONFIG_STAT_0_M_INT_ENB
;
1941 dfx_port_write_byte(bp
, PI_ESIC_K_IO_CONFIG_STAT_0
, tmp
);
1944 dev
->interrupt
= DFX_UNMASK_INTERRUPTS
;
1945 spin_unlock(&bp
->lock
);
1951 * =====================
1952 * = dfx_ctl_get_stats =
1953 * =====================
1956 * Get statistics for FDDI adapter
1959 * Pointer to FDDI statistics structure
1962 * dev - pointer to device information
1964 * Functional Description:
1965 * Gets current MIB objects from adapter, then
1966 * returns FDDI statistics structure as defined
1969 * Note: Since the FDDI statistics structure is
1970 * still new and the device structure doesn't
1971 * have an FDDI-specific get statistics handler,
1972 * we'll return the FDDI statistics structure as
1973 * a pointer to an Ethernet statistics structure.
1974 * That way, at least the first part of the statistics
1975 * structure can be decoded properly, and it allows
1976 * "smart" applications to perform a second cast to
1977 * decode the FDDI-specific statistics.
1979 * We'll have to pay attention to this routine as the
1980 * device structure becomes more mature and LAN media
1993 struct net_device_stats
*dfx_ctl_get_stats(
1994 struct net_device
*dev
1998 DFX_board_t
*bp
= (DFX_board_t
*)dev
->priv
;
2000 /* Fill the bp->stats structure with driver-maintained counters */
2002 bp
->stats
.rx_packets
= bp
->rcv_total_frames
;
2003 bp
->stats
.tx_packets
= bp
->xmt_total_frames
;
2004 bp
->stats
.rx_bytes
= bp
->rcv_total_bytes
;
2005 bp
->stats
.tx_bytes
= bp
->xmt_total_bytes
;
2006 bp
->stats
.rx_errors
= (u32
)(bp
->rcv_crc_errors
+ bp
->rcv_frame_status_errors
+ bp
->rcv_length_errors
);
2007 bp
->stats
.tx_errors
= bp
->xmt_length_errors
;
2008 bp
->stats
.rx_dropped
= bp
->rcv_discards
;
2009 bp
->stats
.tx_dropped
= bp
->xmt_discards
;
2010 bp
->stats
.multicast
= bp
->rcv_multicast_frames
;
2011 bp
->stats
.transmit_collision
= 0; /* always zero (0) for FDDI */
2013 /* Get FDDI SMT MIB objects */
2015 bp
->cmd_req_virt
->cmd_type
= PI_CMD_K_SMT_MIB_GET
;
2016 if (dfx_hw_dma_cmd_req(bp
) != DFX_K_SUCCESS
)
2017 return((struct net_device_stats
*) &bp
->stats
);
2019 /* Fill the bp->stats structure with the SMT MIB object values */
2021 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
));
2022 bp
->stats
.smt_op_version_id
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_op_version_id
;
2023 bp
->stats
.smt_hi_version_id
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_hi_version_id
;
2024 bp
->stats
.smt_lo_version_id
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_lo_version_id
;
2025 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
));
2026 bp
->stats
.smt_mib_version_id
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_mib_version_id
;
2027 bp
->stats
.smt_mac_cts
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_mac_ct
;
2028 bp
->stats
.smt_non_master_cts
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_non_master_ct
;
2029 bp
->stats
.smt_master_cts
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_master_ct
;
2030 bp
->stats
.smt_available_paths
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_available_paths
;
2031 bp
->stats
.smt_config_capabilities
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_config_capabilities
;
2032 bp
->stats
.smt_config_policy
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_config_policy
;
2033 bp
->stats
.smt_connection_policy
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_connection_policy
;
2034 bp
->stats
.smt_t_notify
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_t_notify
;
2035 bp
->stats
.smt_stat_rpt_policy
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_stat_rpt_policy
;
2036 bp
->stats
.smt_trace_max_expiration
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_trace_max_expiration
;
2037 bp
->stats
.smt_bypass_present
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_bypass_present
;
2038 bp
->stats
.smt_ecm_state
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_ecm_state
;
2039 bp
->stats
.smt_cf_state
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_cf_state
;
2040 bp
->stats
.smt_remote_disconnect_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_remote_disconnect_flag
;
2041 bp
->stats
.smt_station_status
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_station_status
;
2042 bp
->stats
.smt_peer_wrap_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_peer_wrap_flag
;
2043 bp
->stats
.smt_time_stamp
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_msg_time_stamp
.ls
;
2044 bp
->stats
.smt_transition_time_stamp
= bp
->cmd_rsp_virt
->smt_mib_get
.smt_transition_time_stamp
.ls
;
2045 bp
->stats
.mac_frame_status_functions
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_frame_status_functions
;
2046 bp
->stats
.mac_t_max_capability
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_t_max_capability
;
2047 bp
->stats
.mac_tvx_capability
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_tvx_capability
;
2048 bp
->stats
.mac_available_paths
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_available_paths
;
2049 bp
->stats
.mac_current_path
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_current_path
;
2050 memcpy(bp
->stats
.mac_upstream_nbr
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_upstream_nbr
, FDDI_K_ALEN
);
2051 memcpy(bp
->stats
.mac_downstream_nbr
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_downstream_nbr
, FDDI_K_ALEN
);
2052 memcpy(bp
->stats
.mac_old_upstream_nbr
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_old_upstream_nbr
, FDDI_K_ALEN
);
2053 memcpy(bp
->stats
.mac_old_downstream_nbr
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_old_downstream_nbr
, FDDI_K_ALEN
);
2054 bp
->stats
.mac_dup_address_test
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_dup_address_test
;
2055 bp
->stats
.mac_requested_paths
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_requested_paths
;
2056 bp
->stats
.mac_downstream_port_type
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_downstream_port_type
;
2057 memcpy(bp
->stats
.mac_smt_address
, &bp
->cmd_rsp_virt
->smt_mib_get
.mac_smt_address
, FDDI_K_ALEN
);
2058 bp
->stats
.mac_t_req
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_t_req
;
2059 bp
->stats
.mac_t_neg
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_t_neg
;
2060 bp
->stats
.mac_t_max
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_t_max
;
2061 bp
->stats
.mac_tvx_value
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_tvx_value
;
2062 bp
->stats
.mac_frame_error_threshold
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_frame_error_threshold
;
2063 bp
->stats
.mac_frame_error_ratio
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_frame_error_ratio
;
2064 bp
->stats
.mac_rmt_state
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_rmt_state
;
2065 bp
->stats
.mac_da_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_da_flag
;
2066 bp
->stats
.mac_una_da_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_unda_flag
;
2067 bp
->stats
.mac_frame_error_flag
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_frame_error_flag
;
2068 bp
->stats
.mac_ma_unitdata_available
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_ma_unitdata_available
;
2069 bp
->stats
.mac_hardware_present
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_hardware_present
;
2070 bp
->stats
.mac_ma_unitdata_enable
= bp
->cmd_rsp_virt
->smt_mib_get
.mac_ma_unitdata_enable
;
2071 bp
->stats
.path_tvx_lower_bound
= bp
->cmd_rsp_virt
->smt_mib_get
.path_tvx_lower_bound
;
2072 bp
->stats
.path_t_max_lower_bound
= bp
->cmd_rsp_virt
->smt_mib_get
.path_t_max_lower_bound
;
2073 bp
->stats
.path_max_t_req
= bp
->cmd_rsp_virt
->smt_mib_get
.path_max_t_req
;
2074 memcpy(bp
->stats
.path_configuration
, &bp
->cmd_rsp_virt
->smt_mib_get
.path_configuration
, sizeof(bp
->cmd_rsp_virt
->smt_mib_get
.path_configuration
));
2075 bp
->stats
.port_my_type
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_my_type
[0];
2076 bp
->stats
.port_my_type
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_my_type
[1];
2077 bp
->stats
.port_neighbor_type
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_neighbor_type
[0];
2078 bp
->stats
.port_neighbor_type
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_neighbor_type
[1];
2079 bp
->stats
.port_connection_policies
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connection_policies
[0];
2080 bp
->stats
.port_connection_policies
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connection_policies
[1];
2081 bp
->stats
.port_mac_indicated
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_mac_indicated
[0];
2082 bp
->stats
.port_mac_indicated
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_mac_indicated
[1];
2083 bp
->stats
.port_current_path
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_current_path
[0];
2084 bp
->stats
.port_current_path
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_current_path
[1];
2085 memcpy(&bp
->stats
.port_requested_paths
[0*3], &bp
->cmd_rsp_virt
->smt_mib_get
.port_requested_paths
[0], 3);
2086 memcpy(&bp
->stats
.port_requested_paths
[1*3], &bp
->cmd_rsp_virt
->smt_mib_get
.port_requested_paths
[1], 3);
2087 bp
->stats
.port_mac_placement
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_mac_placement
[0];
2088 bp
->stats
.port_mac_placement
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_mac_placement
[1];
2089 bp
->stats
.port_available_paths
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_available_paths
[0];
2090 bp
->stats
.port_available_paths
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_available_paths
[1];
2091 bp
->stats
.port_pmd_class
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pmd_class
[0];
2092 bp
->stats
.port_pmd_class
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pmd_class
[1];
2093 bp
->stats
.port_connection_capabilities
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connection_capabilities
[0];
2094 bp
->stats
.port_connection_capabilities
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connection_capabilities
[1];
2095 bp
->stats
.port_bs_flag
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_bs_flag
[0];
2096 bp
->stats
.port_bs_flag
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_bs_flag
[1];
2097 bp
->stats
.port_ler_estimate
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_estimate
[0];
2098 bp
->stats
.port_ler_estimate
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_estimate
[1];
2099 bp
->stats
.port_ler_cutoff
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_cutoff
[0];
2100 bp
->stats
.port_ler_cutoff
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_cutoff
[1];
2101 bp
->stats
.port_ler_alarm
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_alarm
[0];
2102 bp
->stats
.port_ler_alarm
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_alarm
[1];
2103 bp
->stats
.port_connect_state
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connect_state
[0];
2104 bp
->stats
.port_connect_state
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_connect_state
[1];
2105 bp
->stats
.port_pcm_state
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pcm_state
[0];
2106 bp
->stats
.port_pcm_state
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pcm_state
[1];
2107 bp
->stats
.port_pc_withhold
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pc_withhold
[0];
2108 bp
->stats
.port_pc_withhold
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_pc_withhold
[1];
2109 bp
->stats
.port_ler_flag
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_flag
[0];
2110 bp
->stats
.port_ler_flag
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_ler_flag
[1];
2111 bp
->stats
.port_hardware_present
[0] = bp
->cmd_rsp_virt
->smt_mib_get
.port_hardware_present
[0];
2112 bp
->stats
.port_hardware_present
[1] = bp
->cmd_rsp_virt
->smt_mib_get
.port_hardware_present
[1];
2114 /* Get FDDI counters */
2116 bp
->cmd_req_virt
->cmd_type
= PI_CMD_K_CNTRS_GET
;
2117 if (dfx_hw_dma_cmd_req(bp
) != DFX_K_SUCCESS
)
2118 return((struct net_device_stats
*) &bp
->stats
);
2120 /* Fill the bp->stats structure with the FDDI counter values */
2122 bp
->stats
.mac_frame_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.frame_cnt
.ls
;
2123 bp
->stats
.mac_copied_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.copied_cnt
.ls
;
2124 bp
->stats
.mac_transmit_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.transmit_cnt
.ls
;
2125 bp
->stats
.mac_error_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.error_cnt
.ls
;
2126 bp
->stats
.mac_lost_cts
= bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lost_cnt
.ls
;
2127 bp
->stats
.port_lct_fail_cts
[0] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lct_rejects
[0].ls
;
2128 bp
->stats
.port_lct_fail_cts
[1] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lct_rejects
[1].ls
;
2129 bp
->stats
.port_lem_reject_cts
[0] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lem_rejects
[0].ls
;
2130 bp
->stats
.port_lem_reject_cts
[1] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.lem_rejects
[1].ls
;
2131 bp
->stats
.port_lem_cts
[0] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.link_errors
[0].ls
;
2132 bp
->stats
.port_lem_cts
[1] = bp
->cmd_rsp_virt
->cntrs_get
.cntrs
.link_errors
[1].ls
;
2134 return((struct net_device_stats
*) &bp
->stats
);
2139 * ==============================
2140 * = dfx_ctl_set_multicast_list =
2141 * ==============================
2144 * Enable/Disable LLC frame promiscuous mode reception
2145 * on the adapter and/or update multicast address table.
2151 * dev - pointer to device information
2153 * Functional Description:
2154 * This routine follows a fairly simple algorithm for setting the
2155 * adapter filters and CAM:
2157 * if IFF_PROMISC flag is set
2158 * enable LLC individual/group promiscuous mode
2160 * disable LLC individual/group promiscuous mode
2161 * if number of incoming multicast addresses >
2162 * (CAM max size - number of unicast addresses in CAM)
2163 * enable LLC group promiscuous mode
2164 * set driver-maintained multicast address count to zero
2166 * disable LLC group promiscuous mode
2167 * set driver-maintained multicast address count to incoming count
2168 * update adapter CAM
2169 * update adapter filters
2175 * Multicast addresses are presented in canonical (LSB) format.
2178 * On-board adapter CAM and filters are updated.
2181 void dfx_ctl_set_multicast_list(
2182 struct net_device
*dev
2186 DFX_board_t
*bp
= (DFX_board_t
*)dev
->priv
;
2187 int i
; /* used as index in for loop */
2188 struct dev_mc_list
*dmi
; /* ptr to multicast addr entry */
2190 /* Enable LLC frame promiscuous mode, if necessary */
2192 if (dev
->flags
& IFF_PROMISC
)
2193 bp
->ind_group_prom
= PI_FSTATE_K_PASS
; /* Enable LLC ind/group prom mode */
2195 /* Else, update multicast address table */
2199 bp
->ind_group_prom
= PI_FSTATE_K_BLOCK
; /* Disable LLC ind/group prom mode */
2201 * Check whether incoming multicast address count exceeds table size
2203 * Note: The adapters utilize an on-board 64 entry CAM for
2204 * supporting perfect filtering of multicast packets
2205 * and bridge functions when adding unicast addresses.
2206 * There is no hash function available. To support
2207 * additional multicast addresses, the all multicast
2208 * filter (LLC group promiscuous mode) must be enabled.
2210 * The firmware reserves two CAM entries for SMT-related
2211 * multicast addresses, which leaves 62 entries available.
2212 * The following code ensures that we're not being asked
2213 * to add more than 62 addresses to the CAM. If we are,
2214 * the driver will enable the all multicast filter.
2215 * Should the number of multicast addresses drop below
2216 * the high water mark, the filter will be disabled and
2217 * perfect filtering will be used.
2220 if (dev
->mc_count
> (PI_CMD_ADDR_FILTER_K_SIZE
- bp
->uc_count
))
2222 bp
->group_prom
= PI_FSTATE_K_PASS
; /* Enable LLC group prom mode */
2223 bp
->mc_count
= 0; /* Don't add mc addrs to CAM */
2227 bp
->group_prom
= PI_FSTATE_K_BLOCK
; /* Disable LLC group prom mode */
2228 bp
->mc_count
= dev
->mc_count
; /* Add mc addrs to CAM */
2231 /* Copy addresses to multicast address table, then update adapter CAM */
2233 dmi
= dev
->mc_list
; /* point to first multicast addr */
2234 for (i
=0; i
< bp
->mc_count
; i
++)
2236 memcpy(&bp
->mc_table
[i
*FDDI_K_ALEN
], dmi
->dmi_addr
, FDDI_K_ALEN
);
2237 dmi
= dmi
->next
; /* point to next multicast addr */
2239 if (dfx_ctl_update_cam(bp
) != DFX_K_SUCCESS
)
2241 DBG_printk("%s: Could not update multicast address table!\n", dev
->name
);
2245 DBG_printk("%s: Multicast address table updated! Added %d addresses.\n", dev
->name
, bp
->mc_count
);
2249 /* Update adapter filters */
2251 if (dfx_ctl_update_filters(bp
) != DFX_K_SUCCESS
)
2253 DBG_printk("%s: Could not update adapter filters!\n", dev
->name
);
2257 DBG_printk("%s: Adapter filters updated!\n", dev
->name
);
2264 * ===========================
2265 * = dfx_ctl_set_mac_address =
2266 * ===========================
2269 * Add node address override (unicast address) to adapter
2270 * CAM and update dev_addr field in device table.
2276 * dev - pointer to device information
2277 * addr - pointer to sockaddr structure containing unicast address to add
2279 * Functional Description:
2280 * The adapter supports node address overrides by adding one or more
2281 * unicast addresses to the adapter CAM. This is similar to adding
2282 * multicast addresses. In this routine we'll update the driver and
2283 * device structures with the new address, then update the adapter CAM
2284 * to ensure that the adapter will copy and strip frames destined and
2285 * sourced by that address.
2288 * Always returns zero.
2291 * The address pointed to by addr->sa_data is a valid unicast
2292 * address and is presented in canonical (LSB) format.
2295 * On-board adapter CAM is updated. On-board adapter filters
2299 int dfx_ctl_set_mac_address(
2300 struct net_device
*dev
,
2305 DFX_board_t
*bp
= (DFX_board_t
*)dev
->priv
;
2306 struct sockaddr
*p_sockaddr
= (struct sockaddr
*)addr
;
2308 /* Copy unicast address to driver-maintained structs and update count */
2310 memcpy(dev
->dev_addr
, p_sockaddr
->sa_data
, FDDI_K_ALEN
); /* update device struct */
2311 memcpy(&bp
->uc_table
[0], p_sockaddr
->sa_data
, FDDI_K_ALEN
); /* update driver struct */
2315 * Verify we're not exceeding the CAM size by adding unicast address
2317 * Note: It's possible that before entering this routine we've
2318 * already filled the CAM with 62 multicast addresses.
2319 * Since we need to place the node address override into
2320 * the CAM, we have to check to see that we're not
2321 * exceeding the CAM size. If we are, we have to enable
2322 * the LLC group (multicast) promiscuous mode filter as
2323 * in dfx_ctl_set_multicast_list.
2326 if ((bp
->uc_count
+ bp
->mc_count
) > PI_CMD_ADDR_FILTER_K_SIZE
)
2328 bp
->group_prom
= PI_FSTATE_K_PASS
; /* Enable LLC group prom mode */
2329 bp
->mc_count
= 0; /* Don't add mc addrs to CAM */
2331 /* Update adapter filters */
2333 if (dfx_ctl_update_filters(bp
) != DFX_K_SUCCESS
)
2335 DBG_printk("%s: Could not update adapter filters!\n", dev
->name
);
2339 DBG_printk("%s: Adapter filters updated!\n", dev
->name
);
2343 /* Update adapter CAM with new unicast address */
2345 if (dfx_ctl_update_cam(bp
) != DFX_K_SUCCESS
)
2347 DBG_printk("%s: Could not set new MAC address!\n", dev
->name
);
2351 DBG_printk("%s: Adapter CAM updated with new MAC address\n", dev
->name
);
2353 return(0); /* always return zero */
2358 * ======================
2359 * = dfx_ctl_update_cam =
2360 * ======================
2363 * Procedure to update adapter CAM (Content Addressable Memory)
2364 * with desired unicast and multicast address entries.
2370 * bp - pointer to board information
2372 * Functional Description:
2373 * Updates adapter CAM with current contents of board structure
2374 * unicast and multicast address tables. Since there are only 62
2375 * free entries in CAM, this routine ensures that the command
2376 * request buffer is not overrun.
2379 * DFX_K_SUCCESS - Request succeeded
2380 * DFX_K_FAILURE - Request failed
2383 * All addresses being added (unicast and multicast) are in canonical
2387 * On-board adapter CAM is updated.
2390 int dfx_ctl_update_cam(
2395 int i
; /* used as index */
2396 PI_LAN_ADDR
*p_addr
; /* pointer to CAM entry */
2399 * Fill in command request information
2401 * Note: Even though both the unicast and multicast address
2402 * table entries are stored as contiguous 6 byte entries,
2403 * the firmware address filter set command expects each
2404 * entry to be two longwords (8 bytes total). We must be
2405 * careful to only copy the six bytes of each unicast and
2406 * multicast table entry into each command entry. This
2407 * is also why we must first clear the entire command
2411 memset(bp
->cmd_req_virt
, 0, PI_CMD_REQ_K_SIZE_MAX
); /* first clear buffer */
2412 bp
->cmd_req_virt
->cmd_type
= PI_CMD_K_ADDR_FILTER_SET
;
2413 p_addr
= &bp
->cmd_req_virt
->addr_filter_set
.entry
[0];
2415 /* Now add unicast addresses to command request buffer, if any */
2417 for (i
=0; i
< (int)bp
->uc_count
; i
++)
2419 if (i
< PI_CMD_ADDR_FILTER_K_SIZE
)
2421 memcpy(p_addr
, &bp
->uc_table
[i
*FDDI_K_ALEN
], FDDI_K_ALEN
);
2422 p_addr
++; /* point to next command entry */
2426 /* Now add multicast addresses to command request buffer, if any */
2428 for (i
=0; i
< (int)bp
->mc_count
; i
++)
2430 if ((i
+ bp
->uc_count
) < PI_CMD_ADDR_FILTER_K_SIZE
)
2432 memcpy(p_addr
, &bp
->mc_table
[i
*FDDI_K_ALEN
], FDDI_K_ALEN
);
2433 p_addr
++; /* point to next command entry */
2437 /* Issue command to update adapter CAM, then return */
2439 if (dfx_hw_dma_cmd_req(bp
) != DFX_K_SUCCESS
)
2440 return(DFX_K_FAILURE
);
2441 return(DFX_K_SUCCESS
);
2446 * ==========================
2447 * = dfx_ctl_update_filters =
2448 * ==========================
2451 * Procedure to update adapter filters with desired
2458 * bp - pointer to board information
2460 * Functional Description:
2461 * Enables or disables filter using current filter settings.
2464 * DFX_K_SUCCESS - Request succeeded.
2465 * DFX_K_FAILURE - Request failed.
2468 * We must always pass up packets destined to the broadcast
2469 * address (FF-FF-FF-FF-FF-FF), so we'll always keep the
2470 * broadcast filter enabled.
2473 * On-board adapter filters are updated.
2476 int dfx_ctl_update_filters(
2481 int i
= 0; /* used as index */
2483 /* Fill in command request information */
2485 bp
->cmd_req_virt
->cmd_type
= PI_CMD_K_FILTERS_SET
;
2487 /* Initialize Broadcast filter - * ALWAYS ENABLED * */
2489 bp
->cmd_req_virt
->filter_set
.item
[i
].item_code
= PI_ITEM_K_BROADCAST
;
2490 bp
->cmd_req_virt
->filter_set
.item
[i
++].value
= PI_FSTATE_K_PASS
;
2492 /* Initialize LLC Individual/Group Promiscuous filter */
2494 bp
->cmd_req_virt
->filter_set
.item
[i
].item_code
= PI_ITEM_K_IND_GROUP_PROM
;
2495 bp
->cmd_req_virt
->filter_set
.item
[i
++].value
= bp
->ind_group_prom
;
2497 /* Initialize LLC Group Promiscuous filter */
2499 bp
->cmd_req_virt
->filter_set
.item
[i
].item_code
= PI_ITEM_K_GROUP_PROM
;
2500 bp
->cmd_req_virt
->filter_set
.item
[i
++].value
= bp
->group_prom
;
2502 /* Terminate the item code list */
2504 bp
->cmd_req_virt
->filter_set
.item
[i
].item_code
= PI_ITEM_K_EOL
;
2506 /* Issue command to update adapter filters, then return */
2508 if (dfx_hw_dma_cmd_req(bp
) != DFX_K_SUCCESS
)
2509 return(DFX_K_FAILURE
);
2510 return(DFX_K_SUCCESS
);
2515 * ======================
2516 * = dfx_hw_dma_cmd_req =
2517 * ======================
2520 * Sends PDQ DMA command to adapter firmware
2526 * bp - pointer to board information
2528 * Functional Description:
2529 * The command request and response buffers are posted to the adapter in the manner
2530 * described in the PDQ Port Specification:
2532 * 1. Command Response Buffer is posted to adapter.
2533 * 2. Command Request Buffer is posted to adapter.
2534 * 3. Command Request consumer index is polled until it indicates that request
2535 * buffer has been DMA'd to adapter.
2536 * 4. Command Response consumer index is polled until it indicates that response
2537 * buffer has been DMA'd from adapter.
2539 * This ordering ensures that a response buffer is already available for the firmware
2540 * to use once it's done processing the request buffer.
2543 * DFX_K_SUCCESS - DMA command succeeded
2544 * DFX_K_OUTSTATE - Adapter is NOT in proper state
2545 * DFX_K_HW_TIMEOUT - DMA command timed out
2548 * Command request buffer has already been filled with desired DMA command.
2554 int dfx_hw_dma_cmd_req(
2559 int status
; /* adapter status */
2560 int timeout_cnt
; /* used in for loops */
2562 /* Make sure the adapter is in a state that we can issue the DMA command in */
2564 status
= dfx_hw_adap_state_rd(bp
);
2565 if ((status
== PI_STATE_K_RESET
) ||
2566 (status
== PI_STATE_K_HALTED
) ||
2567 (status
== PI_STATE_K_DMA_UNAVAIL
) ||
2568 (status
== PI_STATE_K_UPGRADE
))
2569 return(DFX_K_OUTSTATE
);
2571 /* Put response buffer on the command response queue */
2573 bp
->descr_block_virt
->cmd_rsp
[bp
->cmd_rsp_reg
.index
.prod
].long_0
= (u32
) (PI_RCV_DESCR_M_SOP
|
2574 ((PI_CMD_RSP_K_SIZE_MAX
/ PI_ALIGN_K_CMD_RSP_BUFF
) << PI_RCV_DESCR_V_SEG_LEN
));
2575 bp
->descr_block_virt
->cmd_rsp
[bp
->cmd_rsp_reg
.index
.prod
].long_1
= bp
->cmd_rsp_phys
;
2577 /* Bump (and wrap) the producer index and write out to register */
2579 bp
->cmd_rsp_reg
.index
.prod
+= 1;
2580 bp
->cmd_rsp_reg
.index
.prod
&= PI_CMD_RSP_K_NUM_ENTRIES
-1;
2581 dfx_port_write_long(bp
, PI_PDQ_K_REG_CMD_RSP_PROD
, bp
->cmd_rsp_reg
.lword
);
2583 /* Put request buffer on the command request queue */
2585 bp
->descr_block_virt
->cmd_req
[bp
->cmd_req_reg
.index
.prod
].long_0
= (u32
) (PI_XMT_DESCR_M_SOP
|
2586 PI_XMT_DESCR_M_EOP
| (PI_CMD_REQ_K_SIZE_MAX
<< PI_XMT_DESCR_V_SEG_LEN
));
2587 bp
->descr_block_virt
->cmd_req
[bp
->cmd_req_reg
.index
.prod
].long_1
= bp
->cmd_req_phys
;
2589 /* Bump (and wrap) the producer index and write out to register */
2591 bp
->cmd_req_reg
.index
.prod
+= 1;
2592 bp
->cmd_req_reg
.index
.prod
&= PI_CMD_REQ_K_NUM_ENTRIES
-1;
2593 dfx_port_write_long(bp
, PI_PDQ_K_REG_CMD_REQ_PROD
, bp
->cmd_req_reg
.lword
);
2596 * Here we wait for the command request consumer index to be equal
2597 * to the producer, indicating that the adapter has DMAed the request.
2600 for (timeout_cnt
= 20000; timeout_cnt
> 0; timeout_cnt
--)
2602 if (bp
->cmd_req_reg
.index
.prod
== (u8
)(bp
->cons_block_virt
->cmd_req
))
2604 udelay(100); /* wait for 100 microseconds */
2606 if (timeout_cnt
== 0)
2607 return(DFX_K_HW_TIMEOUT
);
2609 /* Bump (and wrap) the completion index and write out to register */
2611 bp
->cmd_req_reg
.index
.comp
+= 1;
2612 bp
->cmd_req_reg
.index
.comp
&= PI_CMD_REQ_K_NUM_ENTRIES
-1;
2613 dfx_port_write_long(bp
, PI_PDQ_K_REG_CMD_REQ_PROD
, bp
->cmd_req_reg
.lword
);
2616 * Here we wait for the command response consumer index to be equal
2617 * to the producer, indicating that the adapter has DMAed the response.
2620 for (timeout_cnt
= 20000; timeout_cnt
> 0; timeout_cnt
--)
2622 if (bp
->cmd_rsp_reg
.index
.prod
== (u8
)(bp
->cons_block_virt
->cmd_rsp
))
2624 udelay(100); /* wait for 100 microseconds */
2626 if (timeout_cnt
== 0)
2627 return(DFX_K_HW_TIMEOUT
);
2629 /* Bump (and wrap) the completion index and write out to register */
2631 bp
->cmd_rsp_reg
.index
.comp
+= 1;
2632 bp
->cmd_rsp_reg
.index
.comp
&= PI_CMD_RSP_K_NUM_ENTRIES
-1;
2633 dfx_port_write_long(bp
, PI_PDQ_K_REG_CMD_RSP_PROD
, bp
->cmd_rsp_reg
.lword
);
2634 return(DFX_K_SUCCESS
);
2639 * ========================
2640 * = dfx_hw_port_ctrl_req =
2641 * ========================
2644 * Sends PDQ port control command to adapter firmware
2647 * Host data register value in host_data if ptr is not NULL
2650 * bp - pointer to board information
2651 * command - port control command
2652 * data_a - port data A register value
2653 * data_b - port data B register value
2654 * host_data - ptr to host data register value
2656 * Functional Description:
2657 * Send generic port control command to adapter by writing
2658 * to various PDQ port registers, then polling for completion.
2661 * DFX_K_SUCCESS - port control command succeeded
2662 * DFX_K_HW_TIMEOUT - port control command timed out
2671 int dfx_hw_port_ctrl_req(
2676 PI_UINT32
*host_data
2680 PI_UINT32 port_cmd
; /* Port Control command register value */
2681 int timeout_cnt
; /* used in for loops */
2683 /* Set Command Error bit in command longword */
2685 port_cmd
= (PI_UINT32
) (command
| PI_PCTRL_M_CMD_ERROR
);
2687 /* Issue port command to the adapter */
2689 dfx_port_write_long(bp
, PI_PDQ_K_REG_PORT_DATA_A
, data_a
);
2690 dfx_port_write_long(bp
, PI_PDQ_K_REG_PORT_DATA_B
, data_b
);
2691 dfx_port_write_long(bp
, PI_PDQ_K_REG_PORT_CTRL
, port_cmd
);
2693 /* Now wait for command to complete */
2695 if (command
== PI_PCTRL_M_BLAST_FLASH
)
2696 timeout_cnt
= 600000; /* set command timeout count to 60 seconds */
2698 timeout_cnt
= 20000; /* set command timeout count to 2 seconds */
2700 for (; timeout_cnt
> 0; timeout_cnt
--)
2702 dfx_port_read_long(bp
, PI_PDQ_K_REG_PORT_CTRL
, &port_cmd
);
2703 if (!(port_cmd
& PI_PCTRL_M_CMD_ERROR
))
2705 udelay(100); /* wait for 100 microseconds */
2707 if (timeout_cnt
== 0)
2708 return(DFX_K_HW_TIMEOUT
);
2711 * If the address of host_data is non-zero, assume caller has supplied a
2712 * non NULL pointer, and return the contents of the HOST_DATA register in
2716 if (host_data
!= NULL
)
2717 dfx_port_read_long(bp
, PI_PDQ_K_REG_HOST_DATA
, host_data
);
2718 return(DFX_K_SUCCESS
);
2723 * =====================
2724 * = dfx_hw_adap_reset =
2725 * =====================
2734 * bp - pointer to board information
2735 * type - type of reset to perform
2737 * Functional Description:
2738 * Issue soft reset to adapter by writing to PDQ Port Reset
2739 * register. Use incoming reset type to tell adapter what
2740 * kind of reset operation to perform.
2746 * This routine merely issues a soft reset to the adapter.
2747 * It is expected that after this routine returns, the caller
2748 * will appropriately poll the Port Status register for the
2749 * adapter to enter the proper state.
2752 * Internal adapter registers are cleared.
2755 void dfx_hw_adap_reset(
2761 /* Set Reset type and assert reset */
2763 dfx_port_write_long(bp
, PI_PDQ_K_REG_PORT_DATA_A
, type
); /* tell adapter type of reset */
2764 dfx_port_write_long(bp
, PI_PDQ_K_REG_PORT_RESET
, PI_RESET_M_ASSERT_RESET
);
2766 /* Wait for at least 1 Microsecond according to the spec. We wait 20 just to be safe */
2770 /* Deassert reset */
2772 dfx_port_write_long(bp
, PI_PDQ_K_REG_PORT_RESET
, 0);
2778 * ========================
2779 * = dfx_hw_adap_state_rd =
2780 * ========================
2783 * Returns current adapter state
2786 * Adapter state per PDQ Port Specification
2789 * bp - pointer to board information
2791 * Functional Description:
2792 * Reads PDQ Port Status register and returns adapter state.
2804 int dfx_hw_adap_state_rd(
2809 PI_UINT32 port_status
; /* Port Status register value */
2811 dfx_port_read_long(bp
, PI_PDQ_K_REG_PORT_STATUS
, &port_status
);
2812 return((port_status
& PI_PSTATUS_M_STATE
) >> PI_PSTATUS_V_STATE
);
2817 * =====================
2818 * = dfx_hw_dma_uninit =
2819 * =====================
2822 * Brings adapter to DMA_UNAVAILABLE state
2828 * bp - pointer to board information
2829 * type - type of reset to perform
2831 * Functional Description:
2832 * Bring adapter to DMA_UNAVAILABLE state by performing the following:
2833 * 1. Set reset type bit in Port Data A Register then reset adapter.
2834 * 2. Check that adapter is in DMA_UNAVAILABLE state.
2837 * DFX_K_SUCCESS - adapter is in DMA_UNAVAILABLE state
2838 * DFX_K_HW_TIMEOUT - adapter did not reset properly
2844 * Internal adapter registers are cleared.
2847 int dfx_hw_dma_uninit(
2853 int timeout_cnt
; /* used in for loops */
2855 /* Set reset type bit and reset adapter */
2857 dfx_hw_adap_reset(bp
, type
);
2859 /* Now wait for adapter to enter DMA_UNAVAILABLE state */
2861 for (timeout_cnt
= 100000; timeout_cnt
> 0; timeout_cnt
--)
2863 if (dfx_hw_adap_state_rd(bp
) == PI_STATE_K_DMA_UNAVAIL
)
2865 udelay(100); /* wait for 100 microseconds */
2867 if (timeout_cnt
== 0)
2868 return(DFX_K_HW_TIMEOUT
);
2869 return(DFX_K_SUCCESS
);
2874 * Align an sk_buff to a boundary power of 2
2878 void my_skb_align(struct sk_buff
*skb
, int n
)
2880 u32 x
=(u32
)skb
->data
; /* We only want the low bits .. */
2883 v
=(x
+n
-1)&~(n
-1); /* Where we want to be */
2885 skb_reserve(skb
, v
-x
);
2895 * Produces buffers to adapter LLC Host receive descriptor block
2901 * bp - pointer to board information
2903 * Functional Description:
2904 * This routine can be called during dfx_adap_init() or during an adapter
2905 * reset. It initializes the descriptor block and produces all allocated
2906 * LLC Host queue receive buffers.
2912 * The PDQ has been reset and the adapter and driver maintained Type 2
2913 * register indices are cleared.
2916 * Receive buffers are posted to the adapter LLC queue and the adapter
2925 int i
, j
; /* used in for loop */
2928 * Since each receive buffer is a single fragment of same length, initialize
2929 * first longword in each receive descriptor for entire LLC Host descriptor
2930 * block. Also initialize second longword in each receive descriptor with
2931 * physical address of receive buffer. We'll always allocate receive
2932 * buffers in powers of 2 so that we can easily fill the 256 entry descriptor
2933 * block and produce new receive buffers by simply updating the receive
2937 * To support all shipping versions of PDQ, the receive buffer size
2938 * must be mod 128 in length and the physical address must be 128 byte
2939 * aligned. In other words, bits 0-6 of the length and address must
2940 * be zero for the following descriptor field entries to be correct on
2941 * all PDQ-based boards. We guaranteed both requirements during
2942 * driver initialization when we allocated memory for the receive buffers.
2945 #ifdef DYNAMIC_BUFFERS
2946 for (i
= 0; i
< (int)(bp
->rcv_bufs_to_post
); i
++)
2947 for (j
= 0; (i
+ j
) < (int)PI_RCV_DATA_K_NUM_ENTRIES
; j
+= bp
->rcv_bufs_to_post
)
2949 struct sk_buff
*newskb
;
2950 bp
->descr_block_virt
->rcv_data
[i
+j
].long_0
= (u32
) (PI_RCV_DESCR_M_SOP
|
2951 ((PI_RCV_DATA_K_SIZE_MAX
/ PI_ALIGN_K_RCV_DATA_BUFF
) << PI_RCV_DESCR_V_SEG_LEN
));
2952 newskb
= dev_alloc_skb(NEW_SKB_SIZE
);
2954 * align to 128 bytes for compatibility with
2955 * the old EISA boards.
2958 my_skb_align(newskb
,128);
2959 bp
->descr_block_virt
->rcv_data
[i
+j
].long_1
= virt_to_bus(newskb
->data
);
2961 * p_rcv_buff_va is only used inside the
2962 * kernel so we put the skb pointer here.
2964 bp
->p_rcv_buff_va
[i
+j
] = (char *) newskb
;
2967 for (i
=0; i
< (int)(bp
->rcv_bufs_to_post
); i
++)
2968 for (j
=0; (i
+ j
) < (int)PI_RCV_DATA_K_NUM_ENTRIES
; j
+= bp
->rcv_bufs_to_post
)
2970 bp
->descr_block_virt
->rcv_data
[i
+j
].long_0
= (u32
) (PI_RCV_DESCR_M_SOP
|
2971 ((PI_RCV_DATA_K_SIZE_MAX
/ PI_ALIGN_K_RCV_DATA_BUFF
) << PI_RCV_DESCR_V_SEG_LEN
));
2972 bp
->descr_block_virt
->rcv_data
[i
+j
].long_1
= (u32
) (bp
->rcv_block_phys
+ (i
* PI_RCV_DATA_K_SIZE_MAX
));
2973 bp
->p_rcv_buff_va
[i
+j
] = (char *) (bp
->rcv_block_virt
+ (i
* PI_RCV_DATA_K_SIZE_MAX
));
2977 /* Update receive producer and Type 2 register */
2979 bp
->rcv_xmt_reg
.index
.rcv_prod
= bp
->rcv_bufs_to_post
;
2980 dfx_port_write_long(bp
, PI_PDQ_K_REG_TYPE_2_PROD
, bp
->rcv_xmt_reg
.lword
);
2986 * =========================
2987 * = dfx_rcv_queue_process =
2988 * =========================
2991 * Process received LLC frames.
2997 * bp - pointer to board information
2999 * Functional Description:
3000 * Received LLC frames are processed until there are no more consumed frames.
3001 * Once all frames are processed, the receive buffers are returned to the
3002 * adapter. Note that this algorithm fixes the length of time that can be spent
3003 * in this routine, because there are a fixed number of receive buffers to
3004 * process and buffers are not produced until this routine exits and returns
3017 void dfx_rcv_queue_process(
3022 PI_TYPE_2_CONSUMER
*p_type_2_cons
; /* ptr to rcv/xmt consumer block register */
3023 char *p_buff
; /* ptr to start of packet receive buffer (FMC descriptor) */
3024 u32 descr
, pkt_len
; /* FMC descriptor field and packet length */
3025 struct sk_buff
*skb
; /* pointer to a sk_buff to hold incoming packet data */
3027 /* Service all consumed LLC receive frames */
3029 p_type_2_cons
= (PI_TYPE_2_CONSUMER
*)(&bp
->cons_block_virt
->xmt_rcv_data
);
3030 while (bp
->rcv_xmt_reg
.index
.rcv_comp
!= p_type_2_cons
->index
.rcv_cons
)
3032 /* Process any errors */
3036 entry
= bp
->rcv_xmt_reg
.index
.rcv_comp
;
3037 #ifdef DYNAMIC_BUFFERS
3038 p_buff
= (char *) (((struct sk_buff
*)bp
->p_rcv_buff_va
[entry
])->data
);
3040 p_buff
= (char *) bp
->p_rcv_buff_va
[entry
];
3042 memcpy(&descr
, p_buff
+ RCV_BUFF_K_DESCR
, sizeof(u32
));
3044 if (descr
& PI_FMC_DESCR_M_RCC_FLUSH
)
3046 if (descr
& PI_FMC_DESCR_M_RCC_CRC
)
3047 bp
->rcv_crc_errors
++;
3049 bp
->rcv_frame_status_errors
++;
3053 int rx_in_place
= 0;
3055 /* The frame was received without errors - verify packet length */
3057 pkt_len
= (u32
)((descr
& PI_FMC_DESCR_M_LEN
) >> PI_FMC_DESCR_V_LEN
);
3058 pkt_len
-= 4; /* subtract 4 byte CRC */
3059 if (!IN_RANGE(pkt_len
, FDDI_K_LLC_ZLEN
, FDDI_K_LLC_LEN
))
3060 bp
->rcv_length_errors
++;
3062 #ifdef DYNAMIC_BUFFERS
3063 if (pkt_len
> SKBUFF_RX_COPYBREAK
) {
3064 struct sk_buff
*newskb
;
3066 newskb
= dev_alloc_skb(NEW_SKB_SIZE
);
3070 my_skb_align(newskb
, 128);
3071 skb
= (struct sk_buff
*)bp
->p_rcv_buff_va
[entry
];
3072 skb_reserve(skb
, RCV_BUFF_K_PADDING
);
3073 bp
->p_rcv_buff_va
[entry
] = (char *)newskb
;
3074 bp
->descr_block_virt
->rcv_data
[entry
].long_1
= virt_to_bus(newskb
->data
);
3079 skb
= dev_alloc_skb(pkt_len
+3); /* alloc new buffer to pass up, add room for PRH */
3082 printk("%s: Could not allocate receive buffer. Dropping packet.\n", bp
->dev
->name
);
3087 #ifndef DYNAMIC_BUFFERS
3091 /* Receive buffer allocated, pass receive packet up */
3093 memcpy(skb
->data
, p_buff
+ RCV_BUFF_K_PADDING
, pkt_len
+3);
3096 skb_reserve(skb
,3); /* adjust data field so that it points to FC byte */
3097 skb_put(skb
, pkt_len
); /* pass up packet length, NOT including CRC */
3098 skb
->dev
= bp
->dev
; /* pass up device pointer */
3100 skb
->protocol
= fddi_type_trans(skb
, bp
->dev
);
3103 /* Update the rcv counters */
3105 bp
->rcv_total_frames
++;
3106 if (*(p_buff
+ RCV_BUFF_K_DA
) & 0x01)
3107 bp
->rcv_multicast_frames
++;
3109 bp
->rcv_total_bytes
+= skb
->len
;
3115 * Advance the producer (for recycling) and advance the completion
3116 * (for servicing received frames). Note that it is okay to
3117 * advance the producer without checking that it passes the
3118 * completion index because they are both advanced at the same
3122 bp
->rcv_xmt_reg
.index
.rcv_prod
+= 1;
3123 bp
->rcv_xmt_reg
.index
.rcv_comp
+= 1;
3130 * =====================
3131 * = dfx_xmt_queue_pkt =
3132 * =====================
3135 * Queues packets for transmission
3141 * skb - pointer to sk_buff to queue for transmission
3142 * dev - pointer to device information
3144 * Functional Description:
3145 * Here we assume that an incoming skb transmit request
3146 * is contained in a single physically contiguous buffer
3147 * in which the virtual address of the start of packet
3148 * (skb->data) can be converted to a physical address
3149 * by using virt_to_bus().
3151 * Since the adapter architecture requires a three byte
3152 * packet request header to prepend the start of packet,
3153 * we'll write the three byte field immediately prior to
3154 * the FC byte. This assumption is valid because we've
3155 * ensured that dev->hard_header_len includes three pad
3156 * bytes. By posting a single fragment to the adapter,
3157 * we'll reduce the number of descriptor fetches and
3158 * bus traffic needed to send the request.
3160 * Also, we can't free the skb until after it's been DMA'd
3161 * out by the adapter, so we'll queue it in the driver and
3162 * return it in dfx_xmt_done.
3165 * 0 - driver queued packet, link is unavailable, or skbuff was bad
3166 * 1 - caller should requeue the sk_buff for later transmission
3169 * First and foremost, we assume the incoming skb pointer
3170 * is NOT NULL and is pointing to a valid sk_buff structure.
3172 * The outgoing packet is complete, starting with the
3173 * frame control byte including the last byte of data,
3174 * but NOT including the 4 byte CRC. We'll let the
3175 * adapter hardware generate and append the CRC.
3177 * The entire packet is stored in one physically
3178 * contiguous buffer which is not cached and whose
3179 * 32-bit physical address can be determined.
3181 * It's vital that this routine is NOT reentered for the
3182 * same board and that the OS is not in another section of
3183 * code (eg. dfx_int_common) for the same board on a
3190 int dfx_xmt_queue_pkt(
3191 struct sk_buff
*skb
,
3192 struct net_device
*dev
3196 DFX_board_t
*bp
= (DFX_board_t
*) dev
->priv
;
3197 u8 prod
; /* local transmit producer index */
3198 PI_XMT_DESCR
*p_xmt_descr
; /* ptr to transmit descriptor block entry */
3199 XMT_DRIVER_DESCR
*p_xmt_drv_descr
; /* ptr to transmit driver descriptor */
3200 unsigned long flags
;
3203 * Verify that incoming transmit request is OK
3205 * Note: The packet size check is consistent with other
3206 * Linux device drivers, although the correct packet
3207 * size should be verified before calling the
3211 if (!IN_RANGE(skb
->len
, FDDI_K_LLC_ZLEN
, FDDI_K_LLC_LEN
))
3213 printk("%s: Invalid packet length - %u bytes\n",
3214 dev
->name
, skb
->len
);
3215 bp
->xmt_length_errors
++; /* bump error counter */
3218 return(0); /* return "success" */
3221 * See if adapter link is available, if not, free buffer
3223 * Note: If the link isn't available, free buffer and return 0
3224 * rather than tell the upper layer to requeue the packet.
3225 * The methodology here is that by the time the link
3226 * becomes available, the packet to be sent will be
3227 * fairly stale. By simply dropping the packet, the
3228 * higher layer protocols will eventually time out
3229 * waiting for response packets which it won't receive.
3232 if (bp
->link_available
== PI_K_FALSE
)
3234 if (dfx_hw_adap_state_rd(bp
) == PI_STATE_K_LINK_AVAIL
) /* is link really available? */
3235 bp
->link_available
= PI_K_TRUE
; /* if so, set flag and continue */
3238 bp
->xmt_discards
++; /* bump error counter */
3239 dev_kfree_skb(skb
); /* free sk_buff now */
3240 return(0); /* return "success" */
3244 spin_lock_irqsave(&bp
->lock
, flags
);
3246 /* Get the current producer and the next free xmt data descriptor */
3248 prod
= bp
->rcv_xmt_reg
.index
.xmt_prod
;
3249 p_xmt_descr
= &(bp
->descr_block_virt
->xmt_data
[prod
]);
3252 * Get pointer to auxiliary queue entry to contain information
3255 * Note: The current xmt producer index will become the
3256 * current xmt completion index when we complete this
3257 * packet later on. So, we'll get the pointer to the
3258 * next auxiliary queue entry now before we bump the
3262 p_xmt_drv_descr
= &(bp
->xmt_drv_descr_blk
[prod
++]); /* also bump producer index */
3264 /* Write the three PRH bytes immediately before the FC byte */
3267 skb
->data
[0] = DFX_PRH0_BYTE
; /* these byte values are defined */
3268 skb
->data
[1] = DFX_PRH1_BYTE
; /* in the Motorola FDDI MAC chip */
3269 skb
->data
[2] = DFX_PRH2_BYTE
; /* specification */
3272 * Write the descriptor with buffer info and bump producer
3274 * Note: Since we need to start DMA from the packet request
3275 * header, we'll add 3 bytes to the DMA buffer length,
3276 * and we'll determine the physical address of the
3277 * buffer from the PRH, not skb->data.
3280 * 1. Packet starts with the frame control (FC) byte
3282 * 2. The 4-byte CRC is not appended to the buffer or
3283 * included in the length.
3284 * 3. Packet length (skb->len) is from FC to end of
3286 * 4. The packet length does not exceed the maximum
3287 * FDDI LLC frame length of 4491 bytes.
3288 * 5. The entire packet is contained in a physically
3289 * contiguous, non-cached, locked memory space
3290 * comprised of a single buffer pointed to by
3292 * 6. The physical address of the start of packet
3293 * can be determined from the virtual address
3294 * by using virt_to_bus() and is only 32-bits
3298 p_xmt_descr
->long_0
= (u32
) (PI_XMT_DESCR_M_SOP
| PI_XMT_DESCR_M_EOP
| ((skb
->len
) << PI_XMT_DESCR_V_SEG_LEN
));
3299 p_xmt_descr
->long_1
= (u32
) virt_to_bus(skb
->data
);
3302 * Verify that descriptor is actually available
3304 * Note: If descriptor isn't available, return 1 which tells
3305 * the upper layer to requeue the packet for later
3308 * We need to ensure that the producer never reaches the
3309 * completion, except to indicate that the queue is empty.
3312 if (prod
== bp
->rcv_xmt_reg
.index
.xmt_comp
)
3315 spin_unlock_irqrestore(&bp
->lock
, flags
);
3316 return(1); /* requeue packet for later */
3320 * Save info for this packet for xmt done indication routine
3322 * Normally, we'd save the producer index in the p_xmt_drv_descr
3323 * structure so that we'd have it handy when we complete this
3324 * packet later (in dfx_xmt_done). However, since the current
3325 * transmit architecture guarantees a single fragment for the
3326 * entire packet, we can simply bump the completion index by
3327 * one (1) for each completed packet.
3329 * Note: If this assumption changes and we're presented with
3330 * an inconsistent number of transmit fragments for packet
3331 * data, we'll need to modify this code to save the current
3332 * transmit producer index.
3335 p_xmt_drv_descr
->p_skb
= skb
;
3337 /* Update Type 2 register */
3339 bp
->rcv_xmt_reg
.index
.xmt_prod
= prod
;
3340 dfx_port_write_long(bp
, PI_PDQ_K_REG_TYPE_2_PROD
, bp
->rcv_xmt_reg
.lword
);
3341 spin_unlock_irqrestore(&bp
->lock
, flags
);
3342 return(0); /* packet queued to adapter */
3352 * Processes all frames that have been transmitted.
3358 * bp - pointer to board information
3360 * Functional Description:
3361 * For all consumed transmit descriptors that have not
3362 * yet been completed, we'll free the skb we were holding
3363 * onto using dev_kfree_skb and bump the appropriate
3370 * The Type 2 register is not updated in this routine. It is
3371 * assumed that it will be updated in the ISR when dfx_xmt_done
3383 XMT_DRIVER_DESCR
*p_xmt_drv_descr
; /* ptr to transmit driver descriptor */
3384 PI_TYPE_2_CONSUMER
*p_type_2_cons
; /* ptr to rcv/xmt consumer block register */
3386 /* Service all consumed transmit frames */
3388 p_type_2_cons
= (PI_TYPE_2_CONSUMER
*)(&bp
->cons_block_virt
->xmt_rcv_data
);
3389 while (bp
->rcv_xmt_reg
.index
.xmt_comp
!= p_type_2_cons
->index
.xmt_cons
)
3391 /* Get pointer to the transmit driver descriptor block information */
3393 p_xmt_drv_descr
= &(bp
->xmt_drv_descr_blk
[bp
->rcv_xmt_reg
.index
.xmt_comp
]);
3395 /* Increment transmit counters */
3397 bp
->xmt_total_frames
++;
3398 bp
->xmt_total_bytes
+= p_xmt_drv_descr
->p_skb
->len
;
3400 /* Return skb to operating system */
3402 dev_kfree_skb(p_xmt_drv_descr
->p_skb
);
3405 * Move to start of next packet by updating completion index
3407 * Here we assume that a transmit packet request is always
3408 * serviced by posting one fragment. We can therefore
3409 * simplify the completion code by incrementing the
3410 * completion index by one. This code will need to be
3411 * modified if this assumption changes. See comments
3412 * in dfx_xmt_queue_pkt for more details.
3415 bp
->rcv_xmt_reg
.index
.xmt_comp
+= 1;
3427 * Processes all frames whether they've been transmitted
3434 * bp - pointer to board information
3436 * Functional Description:
3437 * For all produced transmit descriptors that have not
3438 * yet been completed, we'll free the skb we were holding
3439 * onto using dev_kfree_skb and bump the appropriate
3440 * counters. Of course, it's possible that some of
3441 * these transmit requests actually did go out, but we
3442 * won't make that distinction here. Finally, we'll
3443 * update the consumer index to match the producer.
3449 * This routine does NOT update the Type 2 register. It
3450 * is assumed that this routine is being called during a
3451 * transmit flush interrupt, or a shutdown or close routine.
3462 u32 prod_cons
; /* rcv/xmt consumer block longword */
3463 XMT_DRIVER_DESCR
*p_xmt_drv_descr
; /* ptr to transmit driver descriptor */
3465 /* Flush all outstanding transmit frames */
3467 while (bp
->rcv_xmt_reg
.index
.xmt_comp
!= bp
->rcv_xmt_reg
.index
.xmt_prod
)
3469 /* Get pointer to the transmit driver descriptor block information */
3471 p_xmt_drv_descr
= &(bp
->xmt_drv_descr_blk
[bp
->rcv_xmt_reg
.index
.xmt_comp
]);
3473 /* Return skb to operating system */
3475 dev_kfree_skb(p_xmt_drv_descr
->p_skb
);
3477 /* Increment transmit error counter */
3482 * Move to start of next packet by updating completion index
3484 * Here we assume that a transmit packet request is always
3485 * serviced by posting one fragment. We can therefore
3486 * simplify the completion code by incrementing the
3487 * completion index by one. This code will need to be
3488 * modified if this assumption changes. See comments
3489 * in dfx_xmt_queue_pkt for more details.
3492 bp
->rcv_xmt_reg
.index
.xmt_comp
+= 1;
3495 /* Update the transmit consumer index in the consumer block */
3497 prod_cons
= (u32
)(bp
->cons_block_virt
->xmt_rcv_data
& ~PI_CONS_M_XMT_INDEX
);
3498 prod_cons
|= (u32
)(bp
->rcv_xmt_reg
.index
.xmt_prod
<< PI_CONS_V_XMT_INDEX
);
3499 bp
->cons_block_virt
->xmt_rcv_data
= prod_cons
;
3506 * kernel-compile-command: "gcc -D__KERNEL__ -I/root/linux/include -Wall -Wstrict-prototypes -O2 -pipe -fomit-frame-pointer -fno-strength-reduce -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2 -DCPU=586 -c defxx.c"