2 * smctr.c: A network driver for the SMC Token Ring Adapters.
4 * Written by Jay Schulist <jschlst@samba.org>
6 * This software may be used and distributed according to the terms
7 * of the GNU General Public License, incorporated herein by reference.
9 * This device driver works with the following SMC adapters:
10 * - SMC TokenCard Elite (8115T, chips 825/584)
11 * - SMC TokenCard Elite/A MCA (8115T/A, chips 825/594)
14 * - SMC TokenCard SDK.
17 * JS Jay Schulist <jschlst@samba.org>
20 * 07102000 JS Fixed a timing problem in smctr_wait_cmd();
21 * Also added a bit more discriptive error msgs.
22 * 07122000 JS Fixed problem with detecting a card with
23 * module io/irq/mem specified.
26 * 1. Multicast support.
28 * Initial 2.5 cleanup Alan Cox <alan@redhat.com> 2002/10/28
31 #include <linux/module.h>
32 #include <linux/kernel.h>
33 #include <linux/types.h>
34 #include <linux/fcntl.h>
35 #include <linux/interrupt.h>
36 #include <linux/ptrace.h>
37 #include <linux/ioport.h>
39 #include <linux/slab.h>
40 #include <linux/string.h>
41 #include <linux/time.h>
42 #include <linux/errno.h>
43 #include <linux/init.h>
44 #include <linux/mca-legacy.h>
45 #include <linux/delay.h>
46 #include <linux/netdevice.h>
47 #include <linux/etherdevice.h>
48 #include <linux/skbuff.h>
49 #include <linux/trdevice.h>
50 #include <linux/bitops.h>
52 #include <asm/system.h>
57 #if BITS_PER_LONG == 64
58 #error FIXME: driver does not support 64-bit platforms
61 #include "smctr.h" /* Our Stuff */
62 #include "smctr_firmware.h" /* SMC adapter firmware */
64 static char version
[] __initdata
= KERN_INFO
"smctr.c: v1.4 7/12/00 by jschlst@samba.org\n";
65 static const char cardname
[] = "smctr";
68 #define SMCTR_IO_EXTENT 20
70 #ifdef CONFIG_MCA_LEGACY
71 static unsigned int smctr_posid
= 0x6ec6;
76 /* SMC Name of the Adapter. */
77 static char smctr_name
[] = "SMC TokenCard";
78 static char *smctr_model
= "Unknown";
80 /* Use 0 for production, 1 for verification, 2 for debug, and
81 * 3 for very verbose debug.
86 static unsigned int smctr_debug
= SMCTR_DEBUG
;
88 /* smctr.c prototypes and functions are arranged alphabeticly
89 * for clearity, maintainability and pure old fashion fun.
92 static int smctr_alloc_shared_memory(struct net_device
*dev
);
95 static int smctr_bypass_state(struct net_device
*dev
);
98 static int smctr_checksum_firmware(struct net_device
*dev
);
99 static int __init
smctr_chk_isa(struct net_device
*dev
);
100 static int smctr_chg_rx_mask(struct net_device
*dev
);
101 static int smctr_clear_int(struct net_device
*dev
);
102 static int smctr_clear_trc_reset(int ioaddr
);
103 static int smctr_close(struct net_device
*dev
);
106 static int smctr_decode_firmware(struct net_device
*dev
);
107 static int smctr_disable_16bit(struct net_device
*dev
);
108 static int smctr_disable_adapter_ctrl_store(struct net_device
*dev
);
109 static int smctr_disable_bic_int(struct net_device
*dev
);
112 static int smctr_enable_16bit(struct net_device
*dev
);
113 static int smctr_enable_adapter_ctrl_store(struct net_device
*dev
);
114 static int smctr_enable_adapter_ram(struct net_device
*dev
);
115 static int smctr_enable_bic_int(struct net_device
*dev
);
118 static int __init
smctr_get_boardid(struct net_device
*dev
, int mca
);
119 static int smctr_get_group_address(struct net_device
*dev
);
120 static int smctr_get_functional_address(struct net_device
*dev
);
121 static unsigned int smctr_get_num_rx_bdbs(struct net_device
*dev
);
122 static int smctr_get_physical_drop_number(struct net_device
*dev
);
123 static __u8
*smctr_get_rx_pointer(struct net_device
*dev
, short queue
);
124 static int smctr_get_station_id(struct net_device
*dev
);
125 static struct net_device_stats
*smctr_get_stats(struct net_device
*dev
);
126 static FCBlock
*smctr_get_tx_fcb(struct net_device
*dev
, __u16 queue
,
128 static int smctr_get_upstream_neighbor_addr(struct net_device
*dev
);
131 static int smctr_hardware_send_packet(struct net_device
*dev
,
132 struct net_local
*tp
);
134 static int smctr_init_acbs(struct net_device
*dev
);
135 static int smctr_init_adapter(struct net_device
*dev
);
136 static int smctr_init_card_real(struct net_device
*dev
);
137 static int smctr_init_rx_bdbs(struct net_device
*dev
);
138 static int smctr_init_rx_fcbs(struct net_device
*dev
);
139 static int smctr_init_shared_memory(struct net_device
*dev
);
140 static int smctr_init_tx_bdbs(struct net_device
*dev
);
141 static int smctr_init_tx_fcbs(struct net_device
*dev
);
142 static int smctr_internal_self_test(struct net_device
*dev
);
143 static irqreturn_t
smctr_interrupt(int irq
, void *dev_id
);
144 static int smctr_issue_enable_int_cmd(struct net_device
*dev
,
145 __u16 interrupt_enable_mask
);
146 static int smctr_issue_int_ack(struct net_device
*dev
, __u16 iack_code
,
148 static int smctr_issue_init_timers_cmd(struct net_device
*dev
);
149 static int smctr_issue_init_txrx_cmd(struct net_device
*dev
);
150 static int smctr_issue_insert_cmd(struct net_device
*dev
);
151 static int smctr_issue_read_ring_status_cmd(struct net_device
*dev
);
152 static int smctr_issue_read_word_cmd(struct net_device
*dev
, __u16 aword_cnt
);
153 static int smctr_issue_remove_cmd(struct net_device
*dev
);
154 static int smctr_issue_resume_acb_cmd(struct net_device
*dev
);
155 static int smctr_issue_resume_rx_bdb_cmd(struct net_device
*dev
, __u16 queue
);
156 static int smctr_issue_resume_rx_fcb_cmd(struct net_device
*dev
, __u16 queue
);
157 static int smctr_issue_resume_tx_fcb_cmd(struct net_device
*dev
, __u16 queue
);
158 static int smctr_issue_test_internal_rom_cmd(struct net_device
*dev
);
159 static int smctr_issue_test_hic_cmd(struct net_device
*dev
);
160 static int smctr_issue_test_mac_reg_cmd(struct net_device
*dev
);
161 static int smctr_issue_trc_loopback_cmd(struct net_device
*dev
);
162 static int smctr_issue_tri_loopback_cmd(struct net_device
*dev
);
163 static int smctr_issue_write_byte_cmd(struct net_device
*dev
,
164 short aword_cnt
, void *byte
);
165 static int smctr_issue_write_word_cmd(struct net_device
*dev
,
166 short aword_cnt
, void *word
);
169 static int smctr_join_complete_state(struct net_device
*dev
);
172 static int smctr_link_tx_fcbs_to_bdbs(struct net_device
*dev
);
173 static int smctr_load_firmware(struct net_device
*dev
);
174 static int smctr_load_node_addr(struct net_device
*dev
);
175 static int smctr_lobe_media_test(struct net_device
*dev
);
176 static int smctr_lobe_media_test_cmd(struct net_device
*dev
);
177 static int smctr_lobe_media_test_state(struct net_device
*dev
);
180 static int smctr_make_8025_hdr(struct net_device
*dev
,
181 MAC_HEADER
*rmf
, MAC_HEADER
*tmf
, __u16 ac_fc
);
182 static int smctr_make_access_pri(struct net_device
*dev
,
183 MAC_SUB_VECTOR
*tsv
);
184 static int smctr_make_addr_mod(struct net_device
*dev
, MAC_SUB_VECTOR
*tsv
);
185 static int smctr_make_auth_funct_class(struct net_device
*dev
,
186 MAC_SUB_VECTOR
*tsv
);
187 static int smctr_make_corr(struct net_device
*dev
,
188 MAC_SUB_VECTOR
*tsv
, __u16 correlator
);
189 static int smctr_make_funct_addr(struct net_device
*dev
,
190 MAC_SUB_VECTOR
*tsv
);
191 static int smctr_make_group_addr(struct net_device
*dev
,
192 MAC_SUB_VECTOR
*tsv
);
193 static int smctr_make_phy_drop_num(struct net_device
*dev
,
194 MAC_SUB_VECTOR
*tsv
);
195 static int smctr_make_product_id(struct net_device
*dev
, MAC_SUB_VECTOR
*tsv
);
196 static int smctr_make_station_id(struct net_device
*dev
, MAC_SUB_VECTOR
*tsv
);
197 static int smctr_make_ring_station_status(struct net_device
*dev
,
198 MAC_SUB_VECTOR
*tsv
);
199 static int smctr_make_ring_station_version(struct net_device
*dev
,
200 MAC_SUB_VECTOR
*tsv
);
201 static int smctr_make_tx_status_code(struct net_device
*dev
,
202 MAC_SUB_VECTOR
*tsv
, __u16 tx_fstatus
);
203 static int smctr_make_upstream_neighbor_addr(struct net_device
*dev
,
204 MAC_SUB_VECTOR
*tsv
);
205 static int smctr_make_wrap_data(struct net_device
*dev
,
206 MAC_SUB_VECTOR
*tsv
);
209 static int smctr_open(struct net_device
*dev
);
210 static int smctr_open_tr(struct net_device
*dev
);
213 struct net_device
*smctr_probe(int unit
);
214 static int __init
smctr_probe1(struct net_device
*dev
, int ioaddr
);
215 static int smctr_process_rx_packet(MAC_HEADER
*rmf
, __u16 size
,
216 struct net_device
*dev
, __u16 rx_status
);
219 static int smctr_ram_memory_test(struct net_device
*dev
);
220 static int smctr_rcv_chg_param(struct net_device
*dev
, MAC_HEADER
*rmf
,
222 static int smctr_rcv_init(struct net_device
*dev
, MAC_HEADER
*rmf
,
224 static int smctr_rcv_tx_forward(struct net_device
*dev
, MAC_HEADER
*rmf
);
225 static int smctr_rcv_rq_addr_state_attch(struct net_device
*dev
,
226 MAC_HEADER
*rmf
, __u16
*correlator
);
227 static int smctr_rcv_unknown(struct net_device
*dev
, MAC_HEADER
*rmf
,
229 static int smctr_reset_adapter(struct net_device
*dev
);
230 static int smctr_restart_tx_chain(struct net_device
*dev
, short queue
);
231 static int smctr_ring_status_chg(struct net_device
*dev
);
232 static int smctr_rx_frame(struct net_device
*dev
);
235 static int smctr_send_dat(struct net_device
*dev
);
236 static int smctr_send_packet(struct sk_buff
*skb
, struct net_device
*dev
);
237 static int smctr_send_lobe_media_test(struct net_device
*dev
);
238 static int smctr_send_rpt_addr(struct net_device
*dev
, MAC_HEADER
*rmf
,
240 static int smctr_send_rpt_attch(struct net_device
*dev
, MAC_HEADER
*rmf
,
242 static int smctr_send_rpt_state(struct net_device
*dev
, MAC_HEADER
*rmf
,
244 static int smctr_send_rpt_tx_forward(struct net_device
*dev
,
245 MAC_HEADER
*rmf
, __u16 tx_fstatus
);
246 static int smctr_send_rsp(struct net_device
*dev
, MAC_HEADER
*rmf
,
247 __u16 rcode
, __u16 correlator
);
248 static int smctr_send_rq_init(struct net_device
*dev
);
249 static int smctr_send_tx_forward(struct net_device
*dev
, MAC_HEADER
*rmf
,
251 static int smctr_set_auth_access_pri(struct net_device
*dev
,
252 MAC_SUB_VECTOR
*rsv
);
253 static int smctr_set_auth_funct_class(struct net_device
*dev
,
254 MAC_SUB_VECTOR
*rsv
);
255 static int smctr_set_corr(struct net_device
*dev
, MAC_SUB_VECTOR
*rsv
,
257 static int smctr_set_error_timer_value(struct net_device
*dev
,
258 MAC_SUB_VECTOR
*rsv
);
259 static int smctr_set_frame_forward(struct net_device
*dev
,
260 MAC_SUB_VECTOR
*rsv
, __u8 dc_sc
);
261 static int smctr_set_local_ring_num(struct net_device
*dev
,
262 MAC_SUB_VECTOR
*rsv
);
263 static unsigned short smctr_set_ctrl_attention(struct net_device
*dev
);
264 static void smctr_set_multicast_list(struct net_device
*dev
);
265 static int smctr_set_page(struct net_device
*dev
, __u8
*buf
);
266 static int smctr_set_phy_drop(struct net_device
*dev
,
267 MAC_SUB_VECTOR
*rsv
);
268 static int smctr_set_ring_speed(struct net_device
*dev
);
269 static int smctr_set_rx_look_ahead(struct net_device
*dev
);
270 static int smctr_set_trc_reset(int ioaddr
);
271 static int smctr_setup_single_cmd(struct net_device
*dev
,
272 __u16 command
, __u16 subcommand
);
273 static int smctr_setup_single_cmd_w_data(struct net_device
*dev
,
274 __u16 command
, __u16 subcommand
);
275 static char *smctr_malloc(struct net_device
*dev
, __u16 size
);
276 static int smctr_status_chg(struct net_device
*dev
);
279 static void smctr_timeout(struct net_device
*dev
);
280 static int smctr_trc_send_packet(struct net_device
*dev
, FCBlock
*fcb
,
282 static __u16
smctr_tx_complete(struct net_device
*dev
, __u16 queue
);
283 static unsigned short smctr_tx_move_frame(struct net_device
*dev
,
284 struct sk_buff
*skb
, __u8
*pbuff
, unsigned int bytes
);
287 static int smctr_update_err_stats(struct net_device
*dev
);
288 static int smctr_update_rx_chain(struct net_device
*dev
, __u16 queue
);
289 static int smctr_update_tx_chain(struct net_device
*dev
, FCBlock
*fcb
,
293 static int smctr_wait_cmd(struct net_device
*dev
);
294 static int smctr_wait_while_cbusy(struct net_device
*dev
);
296 #define TO_256_BYTE_BOUNDRY(X) (((X + 0xff) & 0xff00) - X)
297 #define TO_PARAGRAPH_BOUNDRY(X) (((X + 0x0f) & 0xfff0) - X)
298 #define PARAGRAPH_BOUNDRY(X) smctr_malloc(dev, TO_PARAGRAPH_BOUNDRY(X))
300 /* Allocate Adapter Shared Memory.
301 * IMPORTANT NOTE: Any changes to this function MUST be mirrored in the
302 * function "get_num_rx_bdbs" below!!!
304 * Order of memory allocation:
306 * 0. Initial System Configuration Block Pointer
307 * 1. System Configuration Block
308 * 2. System Control Block
309 * 3. Action Command Block
310 * 4. Interrupt Status Block
313 * 6. NON-MAC TX FCB'S
315 * 8. NON-MAC TX BDB'S
317 * 10. NON-MAC RX FCB'S
319 * 12. NON-MAC RX BDB'S
320 * 13. MAC TX Data Buffer( 1, 256 byte buffer)
321 * 14. MAC RX Data Buffer( 1, 256 byte buffer)
323 * 15. NON-MAC TX Data Buffer
324 * 16. NON-MAC RX Data Buffer
326 static int smctr_alloc_shared_memory(struct net_device
*dev
)
328 struct net_local
*tp
= netdev_priv(dev
);
331 printk(KERN_DEBUG
"%s: smctr_alloc_shared_memory\n", dev
->name
);
333 /* Allocate initial System Control Block pointer.
334 * This pointer is located in the last page, last offset - 4.
336 tp
->iscpb_ptr
= (ISCPBlock
*)(tp
->ram_access
+ ((__u32
)64 * 0x400)
337 - (long)ISCP_BLOCK_SIZE
);
339 /* Allocate System Control Blocks. */
340 tp
->scgb_ptr
= (SCGBlock
*)smctr_malloc(dev
, sizeof(SCGBlock
));
341 PARAGRAPH_BOUNDRY(tp
->sh_mem_used
);
343 tp
->sclb_ptr
= (SCLBlock
*)smctr_malloc(dev
, sizeof(SCLBlock
));
344 PARAGRAPH_BOUNDRY(tp
->sh_mem_used
);
346 tp
->acb_head
= (ACBlock
*)smctr_malloc(dev
,
347 sizeof(ACBlock
)*tp
->num_acbs
);
348 PARAGRAPH_BOUNDRY(tp
->sh_mem_used
);
350 tp
->isb_ptr
= (ISBlock
*)smctr_malloc(dev
, sizeof(ISBlock
));
351 PARAGRAPH_BOUNDRY(tp
->sh_mem_used
);
353 tp
->misc_command_data
= (__u16
*)smctr_malloc(dev
, MISC_DATA_SIZE
);
354 PARAGRAPH_BOUNDRY(tp
->sh_mem_used
);
356 /* Allocate transmit FCBs. */
357 tp
->tx_fcb_head
[MAC_QUEUE
] = (FCBlock
*)smctr_malloc(dev
,
358 sizeof(FCBlock
) * tp
->num_tx_fcbs
[MAC_QUEUE
]);
360 tp
->tx_fcb_head
[NON_MAC_QUEUE
] = (FCBlock
*)smctr_malloc(dev
,
361 sizeof(FCBlock
) * tp
->num_tx_fcbs
[NON_MAC_QUEUE
]);
363 tp
->tx_fcb_head
[BUG_QUEUE
] = (FCBlock
*)smctr_malloc(dev
,
364 sizeof(FCBlock
) * tp
->num_tx_fcbs
[BUG_QUEUE
]);
366 /* Allocate transmit BDBs. */
367 tp
->tx_bdb_head
[MAC_QUEUE
] = (BDBlock
*)smctr_malloc(dev
,
368 sizeof(BDBlock
) * tp
->num_tx_bdbs
[MAC_QUEUE
]);
370 tp
->tx_bdb_head
[NON_MAC_QUEUE
] = (BDBlock
*)smctr_malloc(dev
,
371 sizeof(BDBlock
) * tp
->num_tx_bdbs
[NON_MAC_QUEUE
]);
373 tp
->tx_bdb_head
[BUG_QUEUE
] = (BDBlock
*)smctr_malloc(dev
,
374 sizeof(BDBlock
) * tp
->num_tx_bdbs
[BUG_QUEUE
]);
376 /* Allocate receive FCBs. */
377 tp
->rx_fcb_head
[MAC_QUEUE
] = (FCBlock
*)smctr_malloc(dev
,
378 sizeof(FCBlock
) * tp
->num_rx_fcbs
[MAC_QUEUE
]);
380 tp
->rx_fcb_head
[NON_MAC_QUEUE
] = (FCBlock
*)smctr_malloc(dev
,
381 sizeof(FCBlock
) * tp
->num_rx_fcbs
[NON_MAC_QUEUE
]);
383 /* Allocate receive BDBs. */
384 tp
->rx_bdb_head
[MAC_QUEUE
] = (BDBlock
*)smctr_malloc(dev
,
385 sizeof(BDBlock
) * tp
->num_rx_bdbs
[MAC_QUEUE
]);
387 tp
->rx_bdb_end
[MAC_QUEUE
] = (BDBlock
*)smctr_malloc(dev
, 0);
389 tp
->rx_bdb_head
[NON_MAC_QUEUE
] = (BDBlock
*)smctr_malloc(dev
,
390 sizeof(BDBlock
) * tp
->num_rx_bdbs
[NON_MAC_QUEUE
]);
392 tp
->rx_bdb_end
[NON_MAC_QUEUE
] = (BDBlock
*)smctr_malloc(dev
, 0);
394 /* Allocate MAC transmit buffers.
395 * MAC Tx Buffers doen't have to be on an ODD Boundry.
397 tp
->tx_buff_head
[MAC_QUEUE
]
398 = (__u16
*)smctr_malloc(dev
, tp
->tx_buff_size
[MAC_QUEUE
]);
399 tp
->tx_buff_curr
[MAC_QUEUE
] = tp
->tx_buff_head
[MAC_QUEUE
];
400 tp
->tx_buff_end
[MAC_QUEUE
] = (__u16
*)smctr_malloc(dev
, 0);
402 /* Allocate BUG transmit buffers. */
403 tp
->tx_buff_head
[BUG_QUEUE
]
404 = (__u16
*)smctr_malloc(dev
, tp
->tx_buff_size
[BUG_QUEUE
]);
405 tp
->tx_buff_curr
[BUG_QUEUE
] = tp
->tx_buff_head
[BUG_QUEUE
];
406 tp
->tx_buff_end
[BUG_QUEUE
] = (__u16
*)smctr_malloc(dev
, 0);
408 /* Allocate MAC receive data buffers.
409 * MAC Rx buffer doesn't have to be on a 256 byte boundary.
411 tp
->rx_buff_head
[MAC_QUEUE
] = (__u16
*)smctr_malloc(dev
,
412 RX_DATA_BUFFER_SIZE
* tp
->num_rx_bdbs
[MAC_QUEUE
]);
413 tp
->rx_buff_end
[MAC_QUEUE
] = (__u16
*)smctr_malloc(dev
, 0);
415 /* Allocate Non-MAC transmit buffers.
416 * ?? For maximum Netware performance, put Tx Buffers on
417 * ODD Boundry and then restore malloc to Even Boundrys.
419 smctr_malloc(dev
, 1L);
420 tp
->tx_buff_head
[NON_MAC_QUEUE
]
421 = (__u16
*)smctr_malloc(dev
, tp
->tx_buff_size
[NON_MAC_QUEUE
]);
422 tp
->tx_buff_curr
[NON_MAC_QUEUE
] = tp
->tx_buff_head
[NON_MAC_QUEUE
];
423 tp
->tx_buff_end
[NON_MAC_QUEUE
] = (__u16
*)smctr_malloc(dev
, 0);
424 smctr_malloc(dev
, 1L);
426 /* Allocate Non-MAC receive data buffers.
427 * To guarantee a minimum of 256 contigous memory to
428 * UM_Receive_Packet's lookahead pointer, before a page
429 * change or ring end is encountered, place each rx buffer on
430 * a 256 byte boundary.
432 smctr_malloc(dev
, TO_256_BYTE_BOUNDRY(tp
->sh_mem_used
));
433 tp
->rx_buff_head
[NON_MAC_QUEUE
] = (__u16
*)smctr_malloc(dev
,
434 RX_DATA_BUFFER_SIZE
* tp
->num_rx_bdbs
[NON_MAC_QUEUE
]);
435 tp
->rx_buff_end
[NON_MAC_QUEUE
] = (__u16
*)smctr_malloc(dev
, 0);
440 /* Enter Bypass state. */
441 static int smctr_bypass_state(struct net_device
*dev
)
446 printk(KERN_DEBUG
"%s: smctr_bypass_state\n", dev
->name
);
448 err
= smctr_setup_single_cmd(dev
, ACB_CMD_CHANGE_JOIN_STATE
, JS_BYPASS_STATE
);
453 static int smctr_checksum_firmware(struct net_device
*dev
)
455 struct net_local
*tp
= netdev_priv(dev
);
456 __u16 i
, checksum
= 0;
459 printk(KERN_DEBUG
"%s: smctr_checksum_firmware\n", dev
->name
);
461 smctr_enable_adapter_ctrl_store(dev
);
463 for(i
= 0; i
< CS_RAM_SIZE
; i
+= 2)
464 checksum
+= *((__u16
*)(tp
->ram_access
+ i
));
466 tp
->microcode_version
= *(__u16
*)(tp
->ram_access
467 + CS_RAM_VERSION_OFFSET
);
468 tp
->microcode_version
>>= 8;
470 smctr_disable_adapter_ctrl_store(dev
);
478 static int __init
smctr_chk_mca(struct net_device
*dev
)
480 #ifdef CONFIG_MCA_LEGACY
481 struct net_local
*tp
= netdev_priv(dev
);
483 __u8 r1
, r2
, r3
, r4
, r5
;
485 current_slot
= mca_find_unused_adapter(smctr_posid
, 0);
486 if(current_slot
== MCA_NOTFOUND
)
489 mca_set_adapter_name(current_slot
, smctr_name
);
490 mca_mark_as_used(current_slot
);
491 tp
->slot_num
= current_slot
;
493 r1
= mca_read_stored_pos(tp
->slot_num
, 2);
494 r2
= mca_read_stored_pos(tp
->slot_num
, 3);
497 outb(CNFG_POS_CONTROL_REG
, (__u8
)((tp
->slot_num
- 1) | CNFG_SLOT_ENABLE_BIT
));
499 outb(CNFG_POS_CONTROL_REG
, (__u8
)((tp
->slot_num
) | CNFG_SLOT_ENABLE_BIT
));
501 r1
= inb(CNFG_POS_REG1
);
502 r2
= inb(CNFG_POS_REG0
);
504 tp
->bic_type
= BIC_594_CHIP
;
507 r2
= mca_read_stored_pos(tp
->slot_num
, 2);
509 dev
->base_addr
= ((__u16
)r2
<< 8) + (__u16
)0x800;
510 request_region(dev
->base_addr
, SMCTR_IO_EXTENT
, smctr_name
);
513 r5
= mca_read_stored_pos(tp
->slot_num
, 5);
533 if (request_irq(dev
->irq
, smctr_interrupt
, IRQF_SHARED
, smctr_name
, dev
)) {
534 release_region(dev
->base_addr
, SMCTR_IO_EXTENT
);
539 r3
= mca_read_stored_pos(tp
->slot_num
, 3);
540 tp
->ram_base
= ((__u32
)(r3
& 0x7) << 13) + 0x0C0000;
542 tp
->ram_base
+= 0x010000;
544 tp
->ram_base
+= 0xF00000;
550 tp
->ram_usable
= (__u16
)CNFG_SIZE_8KB
<< r3
;
551 tp
->ram_size
= (__u16
)CNFG_SIZE_64KB
;
552 tp
->board_id
|= TOKEN_MEDIA
;
554 r4
= mca_read_stored_pos(tp
->slot_num
, 4);
555 tp
->rom_base
= ((__u32
)(r4
& 0x7) << 13) + 0x0C0000;
557 tp
->rom_base
+= 0x010000;
563 tp
->rom_size
= CNFG_SIZE_8KB
;
566 tp
->rom_size
= CNFG_SIZE_16KB
;
569 tp
->rom_size
= CNFG_SIZE_32KB
;
572 tp
->rom_size
= ROM_DISABLE
;
575 /* Get Media Type. */
576 r5
= mca_read_stored_pos(tp
->slot_num
, 5);
577 r5
&= CNFG_MEDIA_TYPE_MASK
;
581 tp
->media_type
= MEDIA_STP_4
;
585 tp
->media_type
= MEDIA_STP_16
;
589 tp
->media_type
= MEDIA_UTP_16
;
593 tp
->media_type
= MEDIA_UTP_4
;
598 r2
= mca_read_stored_pos(tp
->slot_num
, 2);
600 tp
->mode_bits
|= EARLY_TOKEN_REL
;
603 outb(CNFG_POS_CONTROL_REG
, 0);
605 tp
->board_id
= smctr_get_boardid(dev
, 1);
606 switch(tp
->board_id
& 0xffff)
609 smctr_model
= "8115T/A";
613 if(tp
->extra_info
& CHIP_REV_MASK
)
614 smctr_model
= "8115T rev XE";
616 smctr_model
= "8115T rev XD";
620 smctr_model
= "Unknown";
627 #endif /* CONFIG_MCA_LEGACY */
630 static int smctr_chg_rx_mask(struct net_device
*dev
)
632 struct net_local
*tp
= netdev_priv(dev
);
636 printk(KERN_DEBUG
"%s: smctr_chg_rx_mask\n", dev
->name
);
638 smctr_enable_16bit(dev
);
639 smctr_set_page(dev
, (__u8
*)tp
->ram_access
);
641 if(tp
->mode_bits
& LOOPING_MODE_MASK
)
642 tp
->config_word0
|= RX_OWN_BIT
;
644 tp
->config_word0
&= ~RX_OWN_BIT
;
646 if(tp
->receive_mask
& PROMISCUOUS_MODE
)
647 tp
->config_word0
|= PROMISCUOUS_BIT
;
649 tp
->config_word0
&= ~PROMISCUOUS_BIT
;
651 if(tp
->receive_mask
& ACCEPT_ERR_PACKETS
)
652 tp
->config_word0
|= SAVBAD_BIT
;
654 tp
->config_word0
&= ~SAVBAD_BIT
;
656 if(tp
->receive_mask
& ACCEPT_ATT_MAC_FRAMES
)
657 tp
->config_word0
|= RXATMAC
;
659 tp
->config_word0
&= ~RXATMAC
;
661 if(tp
->receive_mask
& ACCEPT_MULTI_PROM
)
662 tp
->config_word1
|= MULTICAST_ADDRESS_BIT
;
664 tp
->config_word1
&= ~MULTICAST_ADDRESS_BIT
;
666 if(tp
->receive_mask
& ACCEPT_SOURCE_ROUTING_SPANNING
)
667 tp
->config_word1
|= SOURCE_ROUTING_SPANNING_BITS
;
670 if(tp
->receive_mask
& ACCEPT_SOURCE_ROUTING
)
671 tp
->config_word1
|= SOURCE_ROUTING_EXPLORER_BIT
;
673 tp
->config_word1
&= ~SOURCE_ROUTING_SPANNING_BITS
;
676 if((err
= smctr_issue_write_word_cmd(dev
, RW_CONFIG_REGISTER_0
,
682 if((err
= smctr_issue_write_word_cmd(dev
, RW_CONFIG_REGISTER_1
,
688 smctr_disable_16bit(dev
);
693 static int smctr_clear_int(struct net_device
*dev
)
695 struct net_local
*tp
= netdev_priv(dev
);
697 outb((tp
->trc_mask
| CSR_CLRTINT
), dev
->base_addr
+ CSR
);
702 static int smctr_clear_trc_reset(int ioaddr
)
706 r
= inb(ioaddr
+ MSR
);
707 outb(~MSR_RST
& r
, ioaddr
+ MSR
);
713 * The inverse routine to smctr_open().
715 static int smctr_close(struct net_device
*dev
)
717 struct net_local
*tp
= netdev_priv(dev
);
721 netif_stop_queue(dev
);
725 /* Check to see if adapter is already in a closed state. */
726 if(tp
->status
!= OPEN
)
729 smctr_enable_16bit(dev
);
730 smctr_set_page(dev
, (__u8
*)tp
->ram_access
);
732 if((err
= smctr_issue_remove_cmd(dev
)))
734 smctr_disable_16bit(dev
);
740 skb
= skb_dequeue(&tp
->SendSkbQueue
);
751 static int smctr_decode_firmware(struct net_device
*dev
)
753 struct net_local
*tp
= netdev_priv(dev
);
754 short bit
= 0x80, shift
= 12;
755 DECODE_TREE_NODE
*tree
;
763 printk(KERN_DEBUG
"%s: smctr_decode_firmware\n", dev
->name
);
765 weight
= *(long *)(tp
->ptr_ucode
+ WEIGHT_OFFSET
);
766 tsize
= *(__u8
*)(tp
->ptr_ucode
+ TREE_SIZE_OFFSET
);
767 tree
= (DECODE_TREE_NODE
*)(tp
->ptr_ucode
+ TREE_OFFSET
);
768 ucode
= (__u8
*)(tp
->ptr_ucode
+ TREE_OFFSET
769 + (tsize
* sizeof(DECODE_TREE_NODE
)));
770 mem
= (__u16
*)(tp
->ram_access
);
775 while((tree
+ branch
)->tag
!= LEAF
&& weight
)
777 branch
= *ucode
& bit
? (tree
+ branch
)->llink
778 : (tree
+ branch
)->rlink
;
790 buff
|= (tree
+ branch
)->info
<< shift
;
795 *(mem
++) = SWAP_BYTES(buff
);
801 /* The following assumes the Control Store Memory has
802 * been initialized to zero. If the last partial word
803 * is zero, it will not be written.
806 *(mem
++) = SWAP_BYTES(buff
);
811 static int smctr_disable_16bit(struct net_device
*dev
)
817 * On Exit, Adapter is:
818 * 1. TRC is in a reset state and un-initialized.
819 * 2. Adapter memory is enabled.
820 * 3. Control Store memory is out of context (-WCSS is 1).
822 static int smctr_disable_adapter_ctrl_store(struct net_device
*dev
)
824 struct net_local
*tp
= netdev_priv(dev
);
825 int ioaddr
= dev
->base_addr
;
828 printk(KERN_DEBUG
"%s: smctr_disable_adapter_ctrl_store\n", dev
->name
);
830 tp
->trc_mask
|= CSR_WCSS
;
831 outb(tp
->trc_mask
, ioaddr
+ CSR
);
836 static int smctr_disable_bic_int(struct net_device
*dev
)
838 struct net_local
*tp
= netdev_priv(dev
);
839 int ioaddr
= dev
->base_addr
;
841 tp
->trc_mask
= CSR_MSK_ALL
| CSR_MSKCBUSY
842 | CSR_MSKTINT
| CSR_WCSS
;
843 outb(tp
->trc_mask
, ioaddr
+ CSR
);
848 static int smctr_enable_16bit(struct net_device
*dev
)
850 struct net_local
*tp
= netdev_priv(dev
);
853 if(tp
->adapter_bus
== BUS_ISA16_TYPE
)
855 r
= inb(dev
->base_addr
+ LAAR
);
856 outb((r
| LAAR_MEM16ENB
), dev
->base_addr
+ LAAR
);
863 * To enable the adapter control store memory:
864 * 1. Adapter must be in a RESET state.
865 * 2. Adapter memory must be enabled.
866 * 3. Control Store Memory is in context (-WCSS is 0).
868 static int smctr_enable_adapter_ctrl_store(struct net_device
*dev
)
870 struct net_local
*tp
= netdev_priv(dev
);
871 int ioaddr
= dev
->base_addr
;
874 printk(KERN_DEBUG
"%s: smctr_enable_adapter_ctrl_store\n", dev
->name
);
876 smctr_set_trc_reset(ioaddr
);
877 smctr_enable_adapter_ram(dev
);
879 tp
->trc_mask
&= ~CSR_WCSS
;
880 outb(tp
->trc_mask
, ioaddr
+ CSR
);
885 static int smctr_enable_adapter_ram(struct net_device
*dev
)
887 int ioaddr
= dev
->base_addr
;
891 printk(KERN_DEBUG
"%s: smctr_enable_adapter_ram\n", dev
->name
);
893 r
= inb(ioaddr
+ MSR
);
894 outb(MSR_MEMB
| r
, ioaddr
+ MSR
);
899 static int smctr_enable_bic_int(struct net_device
*dev
)
901 struct net_local
*tp
= netdev_priv(dev
);
902 int ioaddr
= dev
->base_addr
;
908 tp
->trc_mask
= CSR_MSKCBUSY
| CSR_WCSS
;
909 outb(tp
->trc_mask
, ioaddr
+ CSR
);
910 r
= inb(ioaddr
+ IRR
);
911 outb(r
| IRR_IEN
, ioaddr
+ IRR
);
915 tp
->trc_mask
= CSR_MSKCBUSY
| CSR_WCSS
;
916 outb(tp
->trc_mask
, ioaddr
+ CSR
);
917 r
= inb(ioaddr
+ IMCCR
);
918 outb(r
| IMCCR_EIL
, ioaddr
+ IMCCR
);
925 static int __init
smctr_chk_isa(struct net_device
*dev
)
927 struct net_local
*tp
= netdev_priv(dev
);
928 int ioaddr
= dev
->base_addr
;
929 __u8 r1
, r2
, b
, chksum
= 0;
935 printk(KERN_DEBUG
"%s: smctr_chk_isa %#4x\n", dev
->name
, ioaddr
);
937 if((ioaddr
& 0x1F) != 0)
940 /* Grab the region so that no one else tries to probe our ioports. */
941 if (!request_region(ioaddr
, SMCTR_IO_EXTENT
, smctr_name
)) {
946 /* Checksum SMC node address */
947 for(i
= 0; i
< 8; i
++)
949 b
= inb(ioaddr
+ LAR0
+ i
);
953 if (chksum
!= NODE_ADDR_CKSUM
)
956 b
= inb(ioaddr
+ BDID
);
957 if(b
!= BRD_ID_8115T
)
959 printk(KERN_ERR
"%s: The adapter found is not supported\n", dev
->name
);
963 /* Check for 8115T Board ID */
965 for(r
= 0; r
< 8; r
++)
967 r1
= inb(ioaddr
+ 0x8 + r
);
971 /* value of RegF adds up the sum to 0xFF */
972 if((r2
!= 0xFF) && (r2
!= 0xEE))
976 tp
->board_id
= smctr_get_boardid(dev
, 0);
977 switch(tp
->board_id
& 0xffff)
980 smctr_model
= "8115T/A";
984 if(tp
->extra_info
& CHIP_REV_MASK
)
985 smctr_model
= "8115T rev XE";
987 smctr_model
= "8115T rev XD";
991 smctr_model
= "Unknown";
995 /* Store BIC type. */
996 tp
->bic_type
= BIC_584_CHIP
;
997 tp
->nic_type
= NIC_825_CHIP
;
1000 tp
->ram_usable
= CNFG_SIZE_16KB
;
1001 tp
->ram_size
= CNFG_SIZE_64KB
;
1003 /* Get 58x Ram Base */
1007 r2
= inb(ioaddr
+ CNFG_LAAR_584
);
1008 r2
&= CNFG_LAAR_MASK
;
1010 r2
|= ((r1
& 0x38) >> 3);
1012 tp
->ram_base
= ((__u32
)r2
<< 16) + (((__u32
)(r1
& 0x7)) << 13);
1016 r1
= inb(ioaddr
+ CNFG_ICR_583
);
1017 r1
&= CNFG_ICR_IR2_584
;
1019 r2
= inb(ioaddr
+ CNFG_IRR_583
);
1020 r2
&= CNFG_IRR_IRQS
; /* 0x60 */
1042 if(tp
->extra_info
& ALTERNATE_IRQ_BIT
)
1059 printk(KERN_ERR
"%s: No IRQ found aborting\n", dev
->name
);
1063 if (request_irq(dev
->irq
, smctr_interrupt
, IRQF_SHARED
, smctr_name
, dev
))
1066 /* Get 58x Rom Base */
1067 r1
= inb(ioaddr
+ CNFG_BIO_583
);
1071 tp
->rom_base
= (__u32
)r1
<< 13;
1073 /* Get 58x Rom Size */
1074 r1
= inb(ioaddr
+ CNFG_BIO_583
);
1077 tp
->rom_size
= ROM_DISABLE
;
1081 tp
->rom_size
= (__u16
)CNFG_SIZE_8KB
<< r1
;
1084 /* Get 58x Boot Status */
1085 r1
= inb(ioaddr
+ CNFG_GP2
);
1087 tp
->mode_bits
&= (~BOOT_STATUS_MASK
);
1089 if(r1
& CNFG_GP2_BOOT_NIBBLE
)
1090 tp
->mode_bits
|= BOOT_TYPE_1
;
1092 /* Get 58x Zero Wait State */
1093 tp
->mode_bits
&= (~ZERO_WAIT_STATE_MASK
);
1095 r1
= inb(ioaddr
+ CNFG_IRR_583
);
1097 if(r1
& CNFG_IRR_ZWS
)
1098 tp
->mode_bits
|= ZERO_WAIT_STATE_8_BIT
;
1100 if(tp
->board_id
& BOARD_16BIT
)
1102 r1
= inb(ioaddr
+ CNFG_LAAR_584
);
1104 if(r1
& CNFG_LAAR_ZWS
)
1105 tp
->mode_bits
|= ZERO_WAIT_STATE_16_BIT
;
1108 /* Get 584 Media Menu */
1109 tp
->media_menu
= 14;
1110 r1
= inb(ioaddr
+ CNFG_IRR_583
);
1112 tp
->mode_bits
&= 0xf8ff; /* (~CNFG_INTERFACE_TYPE_MASK) */
1113 if((tp
->board_id
& TOKEN_MEDIA
) == TOKEN_MEDIA
)
1115 /* Get Advanced Features */
1116 if(((r1
& 0x6) >> 1) == 0x3)
1117 tp
->media_type
|= MEDIA_UTP_16
;
1120 if(((r1
& 0x6) >> 1) == 0x2)
1121 tp
->media_type
|= MEDIA_STP_16
;
1124 if(((r1
& 0x6) >> 1) == 0x1)
1125 tp
->media_type
|= MEDIA_UTP_4
;
1128 tp
->media_type
|= MEDIA_STP_4
;
1132 r1
= inb(ioaddr
+ CNFG_GP2
);
1133 if(!(r1
& 0x2) ) /* GP2_ETRD */
1134 tp
->mode_bits
|= EARLY_TOKEN_REL
;
1136 /* see if the chip is corrupted
1137 if(smctr_read_584_chksum(ioaddr))
1139 printk(KERN_ERR "%s: EEPROM Checksum Failure\n", dev->name);
1140 free_irq(dev->irq, dev);
1149 release_region(ioaddr
, SMCTR_IO_EXTENT
);
1154 static int __init
smctr_get_boardid(struct net_device
*dev
, int mca
)
1156 struct net_local
*tp
= netdev_priv(dev
);
1157 int ioaddr
= dev
->base_addr
;
1161 tp
->board_id
= BoardIdMask
= 0;
1165 BoardIdMask
|= (MICROCHANNEL
+INTERFACE_CHIP
+TOKEN_MEDIA
+PAGED_RAM
+BOARD_16BIT
);
1166 tp
->extra_info
|= (INTERFACE_594_CHIP
+RAM_SIZE_64K
+NIC_825_BIT
+ALTERNATE_IRQ_BIT
+SLOT_16BIT
);
1170 BoardIdMask
|=(INTERFACE_CHIP
+TOKEN_MEDIA
+PAGED_RAM
+BOARD_16BIT
);
1171 tp
->extra_info
|= (INTERFACE_584_CHIP
+ RAM_SIZE_64K
1172 + NIC_825_BIT
+ ALTERNATE_IRQ_BIT
);
1177 r
= inb(ioaddr
+ BID_REG_1
);
1179 outb(r
, ioaddr
+ BID_REG_1
);
1180 r
= inb(ioaddr
+ BID_REG_1
);
1182 if(r
& BID_SIXTEEN_BIT_BIT
)
1184 tp
->extra_info
|= SLOT_16BIT
;
1185 tp
->adapter_bus
= BUS_ISA16_TYPE
;
1188 tp
->adapter_bus
= BUS_ISA8_TYPE
;
1191 tp
->adapter_bus
= BUS_MCA_TYPE
;
1193 /* Get Board Id Byte */
1194 IdByte
= inb(ioaddr
+ BID_BOARD_ID_BYTE
);
1196 /* if Major version > 1.0 then
1202 r1
= inb(ioaddr
+ BID_REG_1
);
1204 r1
|= BID_OTHER_BIT
;
1206 outb(r1
, ioaddr
+ BID_REG_1
);
1207 r1
= inb(ioaddr
+ BID_REG_3
);
1210 r1
|= BID_ENGR_PAGE
;
1212 outb(r1
, ioaddr
+ BID_REG_3
);
1213 r1
= inb(ioaddr
+ BID_REG_1
);
1215 r1
|= (BID_RLA
| BID_OTHER_BIT
);
1217 outb(r1
, ioaddr
+ BID_REG_1
);
1219 r1
= inb(ioaddr
+ BID_REG_1
);
1220 while(r1
& BID_RECALL_DONE_MASK
)
1221 r1
= inb(ioaddr
+ BID_REG_1
);
1223 r
= inb(ioaddr
+ BID_LAR_0
+ BID_REG_6
);
1225 /* clear chip rev bits */
1226 tp
->extra_info
&= ~CHIP_REV_MASK
;
1227 tp
->extra_info
|= ((r
& BID_EEPROM_CHIP_REV_MASK
) << 6);
1229 r1
= inb(ioaddr
+ BID_REG_1
);
1231 r1
|= BID_OTHER_BIT
;
1233 outb(r1
, ioaddr
+ BID_REG_1
);
1234 r1
= inb(ioaddr
+ BID_REG_3
);
1239 outb(r1
, ioaddr
+ BID_REG_3
);
1240 r1
= inb(ioaddr
+ BID_REG_1
);
1245 outb(r1
, ioaddr
+ BID_REG_1
);
1246 r1
= inb(ioaddr
+ BID_REG_1
);
1248 while(r1
& BID_RECALL_DONE_MASK
)
1249 r1
= inb(ioaddr
+ BID_REG_1
);
1251 return (BoardIdMask
);
1254 static int smctr_get_group_address(struct net_device
*dev
)
1256 smctr_issue_read_word_cmd(dev
, RW_INDIVIDUAL_GROUP_ADDR
);
1258 return(smctr_wait_cmd(dev
));
1261 static int smctr_get_functional_address(struct net_device
*dev
)
1263 smctr_issue_read_word_cmd(dev
, RW_FUNCTIONAL_ADDR
);
1265 return(smctr_wait_cmd(dev
));
1268 /* Calculate number of Non-MAC receive BDB's and data buffers.
1269 * This function must simulate allocateing shared memory exactly
1270 * as the allocate_shared_memory function above.
1272 static unsigned int smctr_get_num_rx_bdbs(struct net_device
*dev
)
1274 struct net_local
*tp
= netdev_priv(dev
);
1275 unsigned int mem_used
= 0;
1277 /* Allocate System Control Blocks. */
1278 mem_used
+= sizeof(SCGBlock
);
1280 mem_used
+= TO_PARAGRAPH_BOUNDRY(mem_used
);
1281 mem_used
+= sizeof(SCLBlock
);
1283 mem_used
+= TO_PARAGRAPH_BOUNDRY(mem_used
);
1284 mem_used
+= sizeof(ACBlock
) * tp
->num_acbs
;
1286 mem_used
+= TO_PARAGRAPH_BOUNDRY(mem_used
);
1287 mem_used
+= sizeof(ISBlock
);
1289 mem_used
+= TO_PARAGRAPH_BOUNDRY(mem_used
);
1290 mem_used
+= MISC_DATA_SIZE
;
1292 /* Allocate transmit FCB's. */
1293 mem_used
+= TO_PARAGRAPH_BOUNDRY(mem_used
);
1295 mem_used
+= sizeof(FCBlock
) * tp
->num_tx_fcbs
[MAC_QUEUE
];
1296 mem_used
+= sizeof(FCBlock
) * tp
->num_tx_fcbs
[NON_MAC_QUEUE
];
1297 mem_used
+= sizeof(FCBlock
) * tp
->num_tx_fcbs
[BUG_QUEUE
];
1299 /* Allocate transmit BDBs. */
1300 mem_used
+= sizeof(BDBlock
) * tp
->num_tx_bdbs
[MAC_QUEUE
];
1301 mem_used
+= sizeof(BDBlock
) * tp
->num_tx_bdbs
[NON_MAC_QUEUE
];
1302 mem_used
+= sizeof(BDBlock
) * tp
->num_tx_bdbs
[BUG_QUEUE
];
1304 /* Allocate receive FCBs. */
1305 mem_used
+= sizeof(FCBlock
) * tp
->num_rx_fcbs
[MAC_QUEUE
];
1306 mem_used
+= sizeof(FCBlock
) * tp
->num_rx_fcbs
[NON_MAC_QUEUE
];
1308 /* Allocate receive BDBs. */
1309 mem_used
+= sizeof(BDBlock
) * tp
->num_rx_bdbs
[MAC_QUEUE
];
1311 /* Allocate MAC transmit buffers.
1312 * MAC transmit buffers don't have to be on an ODD Boundry.
1314 mem_used
+= tp
->tx_buff_size
[MAC_QUEUE
];
1316 /* Allocate BUG transmit buffers. */
1317 mem_used
+= tp
->tx_buff_size
[BUG_QUEUE
];
1319 /* Allocate MAC receive data buffers.
1320 * MAC receive buffers don't have to be on a 256 byte boundary.
1322 mem_used
+= RX_DATA_BUFFER_SIZE
* tp
->num_rx_bdbs
[MAC_QUEUE
];
1324 /* Allocate Non-MAC transmit buffers.
1325 * For maximum Netware performance, put Tx Buffers on
1326 * ODD Boundry,and then restore malloc to Even Boundrys.
1329 mem_used
+= tp
->tx_buff_size
[NON_MAC_QUEUE
];
1332 /* CALCULATE NUMBER OF NON-MAC RX BDB'S
1333 * AND NON-MAC RX DATA BUFFERS
1335 * Make sure the mem_used offset at this point is the
1336 * same as in allocate_shared memory or the following
1337 * boundary adjustment will be incorrect (i.e. not allocating
1338 * the non-mac receive buffers above cannot change the 256
1341 * Since this cannot be guaranteed, adding the full 256 bytes
1342 * to the amount of shared memory used at this point will guaranteed
1343 * that the rx data buffers do not overflow shared memory.
1347 return((0xffff - mem_used
) / (RX_DATA_BUFFER_SIZE
+ sizeof(BDBlock
)));
1350 static int smctr_get_physical_drop_number(struct net_device
*dev
)
1352 smctr_issue_read_word_cmd(dev
, RW_PHYSICAL_DROP_NUMBER
);
1354 return(smctr_wait_cmd(dev
));
1357 static __u8
* smctr_get_rx_pointer(struct net_device
*dev
, short queue
)
1359 struct net_local
*tp
= netdev_priv(dev
);
1362 bdb
= (BDBlock
*)((__u32
)tp
->ram_access
1363 + (__u32
)(tp
->rx_fcb_curr
[queue
]->trc_bdb_ptr
));
1365 tp
->rx_fcb_curr
[queue
]->bdb_ptr
= bdb
;
1367 return ((__u8
*)bdb
->data_block_ptr
);
1370 static int smctr_get_station_id(struct net_device
*dev
)
1372 smctr_issue_read_word_cmd(dev
, RW_INDIVIDUAL_MAC_ADDRESS
);
1374 return(smctr_wait_cmd(dev
));
1378 * Get the current statistics. This may be called with the card open
1381 static struct net_device_stats
*smctr_get_stats(struct net_device
*dev
)
1383 struct net_local
*tp
= netdev_priv(dev
);
1385 return ((struct net_device_stats
*)&tp
->MacStat
);
1388 static FCBlock
*smctr_get_tx_fcb(struct net_device
*dev
, __u16 queue
,
1391 struct net_local
*tp
= netdev_priv(dev
);
1394 unsigned short alloc_size
;
1395 unsigned short *temp
;
1397 if(smctr_debug
> 20)
1398 printk(KERN_DEBUG
"smctr_get_tx_fcb\n");
1400 /* check if there is enough FCB blocks */
1401 if(tp
->num_tx_fcbs_used
[queue
] >= tp
->num_tx_fcbs
[queue
])
1402 return ((FCBlock
*)(-1L));
1404 /* round off the input pkt size to the nearest even number */
1405 alloc_size
= (bytes_count
+ 1) & 0xfffe;
1407 /* check if enough mem */
1408 if((tp
->tx_buff_used
[queue
] + alloc_size
) > tp
->tx_buff_size
[queue
])
1409 return ((FCBlock
*)(-1L));
1411 /* check if past the end ;
1412 * if exactly enough mem to end of ring, alloc from front.
1413 * this avoids update of curr when curr = end
1415 if(((unsigned long)(tp
->tx_buff_curr
[queue
]) + alloc_size
)
1416 >= (unsigned long)(tp
->tx_buff_end
[queue
]))
1418 /* check if enough memory from ring head */
1419 alloc_size
= alloc_size
+
1420 (__u16
)((__u32
)tp
->tx_buff_end
[queue
]
1421 - (__u32
)tp
->tx_buff_curr
[queue
]);
1423 if((tp
->tx_buff_used
[queue
] + alloc_size
)
1424 > tp
->tx_buff_size
[queue
])
1426 return ((FCBlock
*)(-1L));
1430 tp
->tx_buff_curr
[queue
] = tp
->tx_buff_head
[queue
];
1433 tp
->tx_buff_used
[queue
] += alloc_size
;
1434 tp
->num_tx_fcbs_used
[queue
]++;
1435 tp
->tx_fcb_curr
[queue
]->frame_length
= bytes_count
;
1436 tp
->tx_fcb_curr
[queue
]->memory_alloc
= alloc_size
;
1437 temp
= tp
->tx_buff_curr
[queue
];
1438 tp
->tx_buff_curr
[queue
]
1439 = (__u16
*)((__u32
)temp
+ (__u32
)((bytes_count
+ 1) & 0xfffe));
1441 pbdb
= tp
->tx_fcb_curr
[queue
]->bdb_ptr
;
1442 pbdb
->buffer_length
= bytes_count
;
1443 pbdb
->data_block_ptr
= temp
;
1444 pbdb
->trc_data_block_ptr
= TRC_POINTER(temp
);
1446 pFCB
= tp
->tx_fcb_curr
[queue
];
1447 tp
->tx_fcb_curr
[queue
] = tp
->tx_fcb_curr
[queue
]->next_ptr
;
1452 static int smctr_get_upstream_neighbor_addr(struct net_device
*dev
)
1454 smctr_issue_read_word_cmd(dev
, RW_UPSTREAM_NEIGHBOR_ADDRESS
);
1456 return(smctr_wait_cmd(dev
));
1459 static int smctr_hardware_send_packet(struct net_device
*dev
,
1460 struct net_local
*tp
)
1462 struct tr_statistics
*tstat
= &tp
->MacStat
;
1463 struct sk_buff
*skb
;
1466 if(smctr_debug
> 10)
1467 printk(KERN_DEBUG
"%s: smctr_hardware_send_packet\n", dev
->name
);
1469 if(tp
->status
!= OPEN
)
1472 if(tp
->monitor_state_ready
!= 1)
1477 /* Send first buffer from queue */
1478 skb
= skb_dequeue(&tp
->SendSkbQueue
);
1484 if(skb
->len
< SMC_HEADER_SIZE
|| skb
->len
> tp
->max_packet_size
) return (-1);
1486 smctr_enable_16bit(dev
);
1487 smctr_set_page(dev
, (__u8
*)tp
->ram_access
);
1489 if((fcb
= smctr_get_tx_fcb(dev
, NON_MAC_QUEUE
, skb
->len
))
1490 == (FCBlock
*)(-1L))
1492 smctr_disable_16bit(dev
);
1496 smctr_tx_move_frame(dev
, skb
,
1497 (__u8
*)fcb
->bdb_ptr
->data_block_ptr
, skb
->len
);
1499 smctr_set_page(dev
, (__u8
*)fcb
);
1501 smctr_trc_send_packet(dev
, fcb
, NON_MAC_QUEUE
);
1504 tstat
->tx_packets
++;
1506 smctr_disable_16bit(dev
);
1512 static int smctr_init_acbs(struct net_device
*dev
)
1514 struct net_local
*tp
= netdev_priv(dev
);
1518 if(smctr_debug
> 10)
1519 printk(KERN_DEBUG
"%s: smctr_init_acbs\n", dev
->name
);
1522 acb
->cmd_done_status
= (ACB_COMMAND_DONE
| ACB_COMMAND_SUCCESSFUL
);
1523 acb
->cmd_info
= ACB_CHAIN_END
;
1526 acb
->data_offset_lo
= 0;
1527 acb
->data_offset_hi
= 0;
1529 = (ACBlock
*)(((char *)acb
) + sizeof(ACBlock
));
1530 acb
->trc_next_ptr
= TRC_POINTER(acb
->next_ptr
);
1532 for(i
= 1; i
< tp
->num_acbs
; i
++)
1534 acb
= acb
->next_ptr
;
1535 acb
->cmd_done_status
1536 = (ACB_COMMAND_DONE
| ACB_COMMAND_SUCCESSFUL
);
1537 acb
->cmd_info
= ACB_CHAIN_END
;
1540 acb
->data_offset_lo
= 0;
1541 acb
->data_offset_hi
= 0;
1543 = (ACBlock
*)(((char *)acb
) + sizeof(ACBlock
));
1544 acb
->trc_next_ptr
= TRC_POINTER(acb
->next_ptr
);
1547 acb
->next_ptr
= tp
->acb_head
;
1548 acb
->trc_next_ptr
= TRC_POINTER(tp
->acb_head
);
1549 tp
->acb_next
= tp
->acb_head
->next_ptr
;
1550 tp
->acb_curr
= tp
->acb_head
->next_ptr
;
1551 tp
->num_acbs_used
= 0;
1556 static int smctr_init_adapter(struct net_device
*dev
)
1558 struct net_local
*tp
= netdev_priv(dev
);
1561 if(smctr_debug
> 10)
1562 printk(KERN_DEBUG
"%s: smctr_init_adapter\n", dev
->name
);
1564 tp
->status
= CLOSED
;
1565 tp
->page_offset_mask
= (tp
->ram_usable
* 1024) - 1;
1566 skb_queue_head_init(&tp
->SendSkbQueue
);
1567 tp
->QueueSkb
= MAX_TX_QUEUE
;
1569 if(!(tp
->group_address_0
& 0x0080))
1570 tp
->group_address_0
|= 0x00C0;
1572 if(!(tp
->functional_address_0
& 0x00C0))
1573 tp
->functional_address_0
|= 0x00C0;
1575 tp
->functional_address
[0] &= 0xFF7F;
1577 if(tp
->authorized_function_classes
== 0)
1578 tp
->authorized_function_classes
= 0x7FFF;
1580 if(tp
->authorized_access_priority
== 0)
1581 tp
->authorized_access_priority
= 0x06;
1583 smctr_disable_bic_int(dev
);
1584 smctr_set_trc_reset(dev
->base_addr
);
1586 smctr_enable_16bit(dev
);
1587 smctr_set_page(dev
, (__u8
*)tp
->ram_access
);
1589 if(smctr_checksum_firmware(dev
))
1591 printk(KERN_ERR
"%s: Previously loaded firmware is missing\n",dev
->name
); return (-ENOENT
);
1594 if((err
= smctr_ram_memory_test(dev
)))
1596 printk(KERN_ERR
"%s: RAM memory test failed.\n", dev
->name
);
1600 smctr_set_rx_look_ahead(dev
);
1601 smctr_load_node_addr(dev
);
1603 /* Initialize adapter for Internal Self Test. */
1604 smctr_reset_adapter(dev
);
1605 if((err
= smctr_init_card_real(dev
)))
1607 printk(KERN_ERR
"%s: Initialization of card failed (%d)\n",
1612 /* This routine clobbers the TRC's internal registers. */
1613 if((err
= smctr_internal_self_test(dev
)))
1615 printk(KERN_ERR
"%s: Card failed internal self test (%d)\n",
1620 /* Re-Initialize adapter's internal registers */
1621 smctr_reset_adapter(dev
);
1622 if((err
= smctr_init_card_real(dev
)))
1624 printk(KERN_ERR
"%s: Initialization of card failed (%d)\n",
1629 smctr_enable_bic_int(dev
);
1631 if((err
= smctr_issue_enable_int_cmd(dev
, TRC_INTERRUPT_ENABLE_MASK
)))
1634 smctr_disable_16bit(dev
);
1639 static int smctr_init_card_real(struct net_device
*dev
)
1641 struct net_local
*tp
= netdev_priv(dev
);
1644 if(smctr_debug
> 10)
1645 printk(KERN_DEBUG
"%s: smctr_init_card_real\n", dev
->name
);
1647 tp
->sh_mem_used
= 0;
1648 tp
->num_acbs
= NUM_OF_ACBS
;
1650 /* Range Check Max Packet Size */
1651 if(tp
->max_packet_size
< 256)
1652 tp
->max_packet_size
= 256;
1655 if(tp
->max_packet_size
> NON_MAC_TX_BUFFER_MEMORY
)
1656 tp
->max_packet_size
= NON_MAC_TX_BUFFER_MEMORY
;
1659 tp
->num_of_tx_buffs
= (NON_MAC_TX_BUFFER_MEMORY
1660 / tp
->max_packet_size
) - 1;
1662 if(tp
->num_of_tx_buffs
> NUM_NON_MAC_TX_FCBS
)
1663 tp
->num_of_tx_buffs
= NUM_NON_MAC_TX_FCBS
;
1666 if(tp
->num_of_tx_buffs
== 0)
1667 tp
->num_of_tx_buffs
= 1;
1670 /* Tx queue constants */
1671 tp
->num_tx_fcbs
[BUG_QUEUE
] = NUM_BUG_TX_FCBS
;
1672 tp
->num_tx_bdbs
[BUG_QUEUE
] = NUM_BUG_TX_BDBS
;
1673 tp
->tx_buff_size
[BUG_QUEUE
] = BUG_TX_BUFFER_MEMORY
;
1674 tp
->tx_buff_used
[BUG_QUEUE
] = 0;
1675 tp
->tx_queue_status
[BUG_QUEUE
] = NOT_TRANSMITING
;
1677 tp
->num_tx_fcbs
[MAC_QUEUE
] = NUM_MAC_TX_FCBS
;
1678 tp
->num_tx_bdbs
[MAC_QUEUE
] = NUM_MAC_TX_BDBS
;
1679 tp
->tx_buff_size
[MAC_QUEUE
] = MAC_TX_BUFFER_MEMORY
;
1680 tp
->tx_buff_used
[MAC_QUEUE
] = 0;
1681 tp
->tx_queue_status
[MAC_QUEUE
] = NOT_TRANSMITING
;
1683 tp
->num_tx_fcbs
[NON_MAC_QUEUE
] = NUM_NON_MAC_TX_FCBS
;
1684 tp
->num_tx_bdbs
[NON_MAC_QUEUE
] = NUM_NON_MAC_TX_BDBS
;
1685 tp
->tx_buff_size
[NON_MAC_QUEUE
] = NON_MAC_TX_BUFFER_MEMORY
;
1686 tp
->tx_buff_used
[NON_MAC_QUEUE
] = 0;
1687 tp
->tx_queue_status
[NON_MAC_QUEUE
] = NOT_TRANSMITING
;
1689 /* Receive Queue Constants */
1690 tp
->num_rx_fcbs
[MAC_QUEUE
] = NUM_MAC_RX_FCBS
;
1691 tp
->num_rx_bdbs
[MAC_QUEUE
] = NUM_MAC_RX_BDBS
;
1693 if(tp
->extra_info
& CHIP_REV_MASK
)
1694 tp
->num_rx_fcbs
[NON_MAC_QUEUE
] = 78; /* 825 Rev. XE */
1696 tp
->num_rx_fcbs
[NON_MAC_QUEUE
] = 7; /* 825 Rev. XD */
1698 tp
->num_rx_bdbs
[NON_MAC_QUEUE
] = smctr_get_num_rx_bdbs(dev
);
1700 smctr_alloc_shared_memory(dev
);
1701 smctr_init_shared_memory(dev
);
1703 if((err
= smctr_issue_init_timers_cmd(dev
)))
1706 if((err
= smctr_issue_init_txrx_cmd(dev
)))
1708 printk(KERN_ERR
"%s: Hardware failure\n", dev
->name
);
1715 static int smctr_init_rx_bdbs(struct net_device
*dev
)
1717 struct net_local
*tp
= netdev_priv(dev
);
1722 if(smctr_debug
> 10)
1723 printk(KERN_DEBUG
"%s: smctr_init_rx_bdbs\n", dev
->name
);
1725 for(i
= 0; i
< NUM_RX_QS_USED
; i
++)
1727 bdb
= tp
->rx_bdb_head
[i
];
1728 buf
= tp
->rx_buff_head
[i
];
1729 bdb
->info
= (BDB_CHAIN_END
| BDB_NO_WARNING
);
1730 bdb
->buffer_length
= RX_DATA_BUFFER_SIZE
;
1731 bdb
->next_ptr
= (BDBlock
*)(((char *)bdb
) + sizeof(BDBlock
));
1732 bdb
->data_block_ptr
= buf
;
1733 bdb
->trc_next_ptr
= TRC_POINTER(bdb
->next_ptr
);
1735 if(i
== NON_MAC_QUEUE
)
1736 bdb
->trc_data_block_ptr
= RX_BUFF_TRC_POINTER(buf
);
1738 bdb
->trc_data_block_ptr
= TRC_POINTER(buf
);
1740 for(j
= 1; j
< tp
->num_rx_bdbs
[i
]; j
++)
1742 bdb
->next_ptr
->back_ptr
= bdb
;
1743 bdb
= bdb
->next_ptr
;
1744 buf
= (__u16
*)((char *)buf
+ RX_DATA_BUFFER_SIZE
);
1745 bdb
->info
= (BDB_NOT_CHAIN_END
| BDB_NO_WARNING
);
1746 bdb
->buffer_length
= RX_DATA_BUFFER_SIZE
;
1747 bdb
->next_ptr
= (BDBlock
*)(((char *)bdb
) + sizeof(BDBlock
));
1748 bdb
->data_block_ptr
= buf
;
1749 bdb
->trc_next_ptr
= TRC_POINTER(bdb
->next_ptr
);
1751 if(i
== NON_MAC_QUEUE
)
1752 bdb
->trc_data_block_ptr
= RX_BUFF_TRC_POINTER(buf
);
1754 bdb
->trc_data_block_ptr
= TRC_POINTER(buf
);
1757 bdb
->next_ptr
= tp
->rx_bdb_head
[i
];
1758 bdb
->trc_next_ptr
= TRC_POINTER(tp
->rx_bdb_head
[i
]);
1760 tp
->rx_bdb_head
[i
]->back_ptr
= bdb
;
1761 tp
->rx_bdb_curr
[i
] = tp
->rx_bdb_head
[i
]->next_ptr
;
1767 static int smctr_init_rx_fcbs(struct net_device
*dev
)
1769 struct net_local
*tp
= netdev_priv(dev
);
1773 for(i
= 0; i
< NUM_RX_QS_USED
; i
++)
1775 fcb
= tp
->rx_fcb_head
[i
];
1776 fcb
->frame_status
= 0;
1777 fcb
->frame_length
= 0;
1778 fcb
->info
= FCB_CHAIN_END
;
1779 fcb
->next_ptr
= (FCBlock
*)(((char*)fcb
) + sizeof(FCBlock
));
1780 if(i
== NON_MAC_QUEUE
)
1781 fcb
->trc_next_ptr
= RX_FCB_TRC_POINTER(fcb
->next_ptr
);
1783 fcb
->trc_next_ptr
= TRC_POINTER(fcb
->next_ptr
);
1785 for(j
= 1; j
< tp
->num_rx_fcbs
[i
]; j
++)
1787 fcb
->next_ptr
->back_ptr
= fcb
;
1788 fcb
= fcb
->next_ptr
;
1789 fcb
->frame_status
= 0;
1790 fcb
->frame_length
= 0;
1791 fcb
->info
= FCB_WARNING
;
1793 = (FCBlock
*)(((char *)fcb
) + sizeof(FCBlock
));
1795 if(i
== NON_MAC_QUEUE
)
1797 = RX_FCB_TRC_POINTER(fcb
->next_ptr
);
1800 = TRC_POINTER(fcb
->next_ptr
);
1803 fcb
->next_ptr
= tp
->rx_fcb_head
[i
];
1805 if(i
== NON_MAC_QUEUE
)
1806 fcb
->trc_next_ptr
= RX_FCB_TRC_POINTER(fcb
->next_ptr
);
1808 fcb
->trc_next_ptr
= TRC_POINTER(fcb
->next_ptr
);
1810 tp
->rx_fcb_head
[i
]->back_ptr
= fcb
;
1811 tp
->rx_fcb_curr
[i
] = tp
->rx_fcb_head
[i
]->next_ptr
;
1817 static int smctr_init_shared_memory(struct net_device
*dev
)
1819 struct net_local
*tp
= netdev_priv(dev
);
1823 if(smctr_debug
> 10)
1824 printk(KERN_DEBUG
"%s: smctr_init_shared_memory\n", dev
->name
);
1826 smctr_set_page(dev
, (__u8
*)(unsigned int)tp
->iscpb_ptr
);
1828 /* Initialize Initial System Configuration Point. (ISCP) */
1829 iscpb
= (__u32
*)PAGE_POINTER(&tp
->iscpb_ptr
->trc_scgb_ptr
);
1830 *iscpb
= (__u32
)(SWAP_WORDS(TRC_POINTER(tp
->scgb_ptr
)));
1832 smctr_set_page(dev
, (__u8
*)tp
->ram_access
);
1834 /* Initialize System Configuration Pointers. (SCP) */
1835 tp
->scgb_ptr
->config
= (SCGB_ADDRESS_POINTER_FORMAT
1836 | SCGB_MULTI_WORD_CONTROL
| SCGB_DATA_FORMAT
1837 | SCGB_BURST_LENGTH
);
1839 tp
->scgb_ptr
->trc_sclb_ptr
= TRC_POINTER(tp
->sclb_ptr
);
1840 tp
->scgb_ptr
->trc_acb_ptr
= TRC_POINTER(tp
->acb_head
);
1841 tp
->scgb_ptr
->trc_isb_ptr
= TRC_POINTER(tp
->isb_ptr
);
1842 tp
->scgb_ptr
->isbsiz
= (sizeof(ISBlock
)) - 2;
1844 /* Initialize System Control Block. (SCB) */
1845 tp
->sclb_ptr
->valid_command
= SCLB_VALID
| SCLB_CMD_NOP
;
1846 tp
->sclb_ptr
->iack_code
= 0;
1847 tp
->sclb_ptr
->resume_control
= 0;
1848 tp
->sclb_ptr
->int_mask_control
= 0;
1849 tp
->sclb_ptr
->int_mask_state
= 0;
1851 /* Initialize Interrupt Status Block. (ISB) */
1852 for(i
= 0; i
< NUM_OF_INTERRUPTS
; i
++)
1854 tp
->isb_ptr
->IStatus
[i
].IType
= 0xf0;
1855 tp
->isb_ptr
->IStatus
[i
].ISubtype
= 0;
1858 tp
->current_isb_index
= 0;
1860 /* Initialize Action Command Block. (ACB) */
1861 smctr_init_acbs(dev
);
1863 /* Initialize transmit FCB's and BDB's. */
1864 smctr_link_tx_fcbs_to_bdbs(dev
);
1865 smctr_init_tx_bdbs(dev
);
1866 smctr_init_tx_fcbs(dev
);
1868 /* Initialize receive FCB's and BDB's. */
1869 smctr_init_rx_bdbs(dev
);
1870 smctr_init_rx_fcbs(dev
);
1875 static int smctr_init_tx_bdbs(struct net_device
*dev
)
1877 struct net_local
*tp
= netdev_priv(dev
);
1881 for(i
= 0; i
< NUM_TX_QS_USED
; i
++)
1883 bdb
= tp
->tx_bdb_head
[i
];
1884 bdb
->info
= (BDB_NOT_CHAIN_END
| BDB_NO_WARNING
);
1885 bdb
->next_ptr
= (BDBlock
*)(((char *)bdb
) + sizeof(BDBlock
));
1886 bdb
->trc_next_ptr
= TRC_POINTER(bdb
->next_ptr
);
1888 for(j
= 1; j
< tp
->num_tx_bdbs
[i
]; j
++)
1890 bdb
->next_ptr
->back_ptr
= bdb
;
1891 bdb
= bdb
->next_ptr
;
1892 bdb
->info
= (BDB_NOT_CHAIN_END
| BDB_NO_WARNING
);
1894 = (BDBlock
*)(((char *)bdb
) + sizeof( BDBlock
)); bdb
->trc_next_ptr
= TRC_POINTER(bdb
->next_ptr
);
1897 bdb
->next_ptr
= tp
->tx_bdb_head
[i
];
1898 bdb
->trc_next_ptr
= TRC_POINTER(tp
->tx_bdb_head
[i
]);
1899 tp
->tx_bdb_head
[i
]->back_ptr
= bdb
;
1905 static int smctr_init_tx_fcbs(struct net_device
*dev
)
1907 struct net_local
*tp
= netdev_priv(dev
);
1911 for(i
= 0; i
< NUM_TX_QS_USED
; i
++)
1913 fcb
= tp
->tx_fcb_head
[i
];
1914 fcb
->frame_status
= 0;
1915 fcb
->frame_length
= 0;
1916 fcb
->info
= FCB_CHAIN_END
;
1917 fcb
->next_ptr
= (FCBlock
*)(((char *)fcb
) + sizeof(FCBlock
));
1918 fcb
->trc_next_ptr
= TRC_POINTER(fcb
->next_ptr
);
1920 for(j
= 1; j
< tp
->num_tx_fcbs
[i
]; j
++)
1922 fcb
->next_ptr
->back_ptr
= fcb
;
1923 fcb
= fcb
->next_ptr
;
1924 fcb
->frame_status
= 0;
1925 fcb
->frame_length
= 0;
1926 fcb
->info
= FCB_CHAIN_END
;
1928 = (FCBlock
*)(((char *)fcb
) + sizeof(FCBlock
));
1929 fcb
->trc_next_ptr
= TRC_POINTER(fcb
->next_ptr
);
1932 fcb
->next_ptr
= tp
->tx_fcb_head
[i
];
1933 fcb
->trc_next_ptr
= TRC_POINTER(tp
->tx_fcb_head
[i
]);
1935 tp
->tx_fcb_head
[i
]->back_ptr
= fcb
;
1936 tp
->tx_fcb_end
[i
] = tp
->tx_fcb_head
[i
]->next_ptr
;
1937 tp
->tx_fcb_curr
[i
] = tp
->tx_fcb_head
[i
]->next_ptr
;
1938 tp
->num_tx_fcbs_used
[i
] = 0;
1944 static int smctr_internal_self_test(struct net_device
*dev
)
1946 struct net_local
*tp
= netdev_priv(dev
);
1949 if((err
= smctr_issue_test_internal_rom_cmd(dev
)))
1952 if((err
= smctr_wait_cmd(dev
)))
1955 if(tp
->acb_head
->cmd_done_status
& 0xff)
1958 if((err
= smctr_issue_test_hic_cmd(dev
)))
1961 if((err
= smctr_wait_cmd(dev
)))
1964 if(tp
->acb_head
->cmd_done_status
& 0xff)
1967 if((err
= smctr_issue_test_mac_reg_cmd(dev
)))
1970 if((err
= smctr_wait_cmd(dev
)))
1973 if(tp
->acb_head
->cmd_done_status
& 0xff)
1980 * The typical workload of the driver: Handle the network interface interrupts.
1982 static irqreturn_t
smctr_interrupt(int irq
, void *dev_id
)
1984 struct net_device
*dev
= dev_id
;
1985 struct net_local
*tp
;
1987 __u16 interrupt_unmask_bits
= 0, interrupt_ack_code
= 0xff00;
1988 __u16 err1
, err
= NOT_MY_INTERRUPT
;
1989 __u8 isb_type
, isb_subtype
;
1992 ioaddr
= dev
->base_addr
;
1993 tp
= netdev_priv(dev
);
1995 if(tp
->status
== NOT_INITIALIZED
)
1998 spin_lock(&tp
->lock
);
2000 smctr_disable_bic_int(dev
);
2001 smctr_enable_16bit(dev
);
2003 smctr_clear_int(dev
);
2005 /* First read the LSB */
2006 while((tp
->isb_ptr
->IStatus
[tp
->current_isb_index
].IType
& 0xf0) == 0)
2008 isb_index
= tp
->current_isb_index
;
2009 isb_type
= tp
->isb_ptr
->IStatus
[isb_index
].IType
;
2010 isb_subtype
= tp
->isb_ptr
->IStatus
[isb_index
].ISubtype
;
2012 (tp
->current_isb_index
)++;
2013 if(tp
->current_isb_index
== NUM_OF_INTERRUPTS
)
2014 tp
->current_isb_index
= 0;
2016 if(isb_type
>= 0x10)
2018 smctr_disable_16bit(dev
);
2019 spin_unlock(&tp
->lock
);
2023 err
= HARDWARE_FAILED
;
2024 interrupt_ack_code
= isb_index
;
2025 tp
->isb_ptr
->IStatus
[isb_index
].IType
|= 0xf0;
2027 interrupt_unmask_bits
|= (1 << (__u16
)isb_type
);
2031 case ISB_IMC_MAC_TYPE_3
:
2032 smctr_disable_16bit(dev
);
2037 tp
->monitor_state
= MS_MONITOR_FSM_INACTIVE
;
2041 tp
->monitor_state
= MS_REPEAT_BEACON_STATE
;
2045 tp
->monitor_state
= MS_REPEAT_CLAIM_TOKEN_STATE
;
2049 tp
->monitor_state
= MS_TRANSMIT_CLAIM_TOKEN_STATE
; break;
2052 tp
->monitor_state
= MS_STANDBY_MONITOR_STATE
;
2056 tp
->monitor_state
= MS_TRANSMIT_BEACON_STATE
;
2060 tp
->monitor_state
= MS_ACTIVE_MONITOR_STATE
;
2064 tp
->monitor_state
= MS_TRANSMIT_RING_PURGE_STATE
;
2067 case 8: /* diagnostic state */
2071 tp
->monitor_state
= MS_BEACON_TEST_STATE
;
2072 if(smctr_lobe_media_test(dev
))
2074 tp
->ring_status_flags
= RING_STATUS_CHANGED
;
2075 tp
->ring_status
= AUTO_REMOVAL_ERROR
;
2076 smctr_ring_status_chg(dev
);
2077 smctr_bypass_state(dev
);
2080 smctr_issue_insert_cmd(dev
);
2083 /* case 0x0a-0xff, illegal states */
2088 tp
->ring_status_flags
= MONITOR_STATE_CHANGED
;
2089 err
= smctr_ring_status_chg(dev
);
2091 smctr_enable_16bit(dev
);
2094 /* Type 0x02 - MAC Error Counters Interrupt
2095 * One or more MAC Error Counter is half full
2096 * MAC Error Counters
2097 * Lost_FR_Error_Counter
2098 * RCV_Congestion_Counter
2099 * FR_copied_Error_Counter
2100 * FREQ_Error_Counter
2101 * Token_Error_Counter
2102 * Line_Error_Counter
2103 * Internal_Error_Count
2105 case ISB_IMC_MAC_ERROR_COUNTERS
:
2106 /* Read 802.5 Error Counters */
2107 err
= smctr_issue_read_ring_status_cmd(dev
);
2110 /* Type 0x04 - MAC Type 2 Interrupt
2111 * HOST needs to enqueue MAC Frame for transmission
2112 * SubType Bit 15 - RQ_INIT_PDU( Request Initialization) * Changed from RQ_INIT_PDU to
2113 * TRC_Status_Changed_Indicate
2115 case ISB_IMC_MAC_TYPE_2
:
2116 err
= smctr_issue_read_ring_status_cmd(dev
);
2120 /* Type 0x05 - TX Frame Interrupt (FI). */
2121 case ISB_IMC_TX_FRAME
:
2122 /* BUG QUEUE for TRC stuck receive BUG */
2123 if(isb_subtype
& TX_PENDING_PRIORITY_2
)
2125 if((err
= smctr_tx_complete(dev
, BUG_QUEUE
)) != SUCCESS
)
2129 /* NON-MAC frames only */
2130 if(isb_subtype
& TX_PENDING_PRIORITY_1
)
2132 if((err
= smctr_tx_complete(dev
, NON_MAC_QUEUE
)) != SUCCESS
)
2136 /* MAC frames only */
2137 if(isb_subtype
& TX_PENDING_PRIORITY_0
)
2138 err
= smctr_tx_complete(dev
, MAC_QUEUE
); break;
2140 /* Type 0x06 - TX END OF QUEUE (FE) */
2141 case ISB_IMC_END_OF_TX_QUEUE
:
2143 if(isb_subtype
& TX_PENDING_PRIORITY_2
)
2145 /* ok to clear Receive FIFO overrun
2146 * imask send_BUG now completes.
2148 interrupt_unmask_bits
|= 0x800;
2150 tp
->tx_queue_status
[BUG_QUEUE
] = NOT_TRANSMITING
;
2151 if((err
= smctr_tx_complete(dev
, BUG_QUEUE
)) != SUCCESS
)
2153 if((err
= smctr_restart_tx_chain(dev
, BUG_QUEUE
)) != SUCCESS
)
2157 /* NON-MAC queue only */
2158 if(isb_subtype
& TX_PENDING_PRIORITY_1
)
2160 tp
->tx_queue_status
[NON_MAC_QUEUE
] = NOT_TRANSMITING
;
2161 if((err
= smctr_tx_complete(dev
, NON_MAC_QUEUE
)) != SUCCESS
)
2163 if((err
= smctr_restart_tx_chain(dev
, NON_MAC_QUEUE
)) != SUCCESS
)
2167 /* MAC queue only */
2168 if(isb_subtype
& TX_PENDING_PRIORITY_0
)
2170 tp
->tx_queue_status
[MAC_QUEUE
] = NOT_TRANSMITING
;
2171 if((err
= smctr_tx_complete(dev
, MAC_QUEUE
)) != SUCCESS
)
2174 err
= smctr_restart_tx_chain(dev
, MAC_QUEUE
);
2178 /* Type 0x07 - NON-MAC RX Resource Interrupt
2179 * Subtype bit 12 - (BW) BDB warning
2180 * Subtype bit 13 - (FW) FCB warning
2181 * Subtype bit 14 - (BE) BDB End of chain
2182 * Subtype bit 15 - (FE) FCB End of chain
2184 case ISB_IMC_NON_MAC_RX_RESOURCE
:
2185 tp
->rx_fifo_overrun_count
= 0;
2186 tp
->receive_queue_number
= NON_MAC_QUEUE
;
2187 err1
= smctr_rx_frame(dev
);
2189 if(isb_subtype
& NON_MAC_RX_RESOURCE_FE
)
2191 if((err
= smctr_issue_resume_rx_fcb_cmd( dev
, NON_MAC_QUEUE
)) != SUCCESS
) break;
2193 if(tp
->ptr_rx_fcb_overruns
)
2194 (*tp
->ptr_rx_fcb_overruns
)++;
2197 if(isb_subtype
& NON_MAC_RX_RESOURCE_BE
)
2199 if((err
= smctr_issue_resume_rx_bdb_cmd( dev
, NON_MAC_QUEUE
)) != SUCCESS
) break;
2201 if(tp
->ptr_rx_bdb_overruns
)
2202 (*tp
->ptr_rx_bdb_overruns
)++;
2207 /* Type 0x08 - MAC RX Resource Interrupt
2208 * Subtype bit 12 - (BW) BDB warning
2209 * Subtype bit 13 - (FW) FCB warning
2210 * Subtype bit 14 - (BE) BDB End of chain
2211 * Subtype bit 15 - (FE) FCB End of chain
2213 case ISB_IMC_MAC_RX_RESOURCE
:
2214 tp
->receive_queue_number
= MAC_QUEUE
;
2215 err1
= smctr_rx_frame(dev
);
2217 if(isb_subtype
& MAC_RX_RESOURCE_FE
)
2219 if((err
= smctr_issue_resume_rx_fcb_cmd( dev
, MAC_QUEUE
)) != SUCCESS
)
2222 if(tp
->ptr_rx_fcb_overruns
)
2223 (*tp
->ptr_rx_fcb_overruns
)++;
2226 if(isb_subtype
& MAC_RX_RESOURCE_BE
)
2228 if((err
= smctr_issue_resume_rx_bdb_cmd( dev
, MAC_QUEUE
)) != SUCCESS
)
2231 if(tp
->ptr_rx_bdb_overruns
)
2232 (*tp
->ptr_rx_bdb_overruns
)++;
2237 /* Type 0x09 - NON_MAC RX Frame Interrupt */
2238 case ISB_IMC_NON_MAC_RX_FRAME
:
2239 tp
->rx_fifo_overrun_count
= 0;
2240 tp
->receive_queue_number
= NON_MAC_QUEUE
;
2241 err
= smctr_rx_frame(dev
);
2244 /* Type 0x0A - MAC RX Frame Interrupt */
2245 case ISB_IMC_MAC_RX_FRAME
:
2246 tp
->receive_queue_number
= MAC_QUEUE
;
2247 err
= smctr_rx_frame(dev
);
2250 /* Type 0x0B - TRC status
2251 * TRC has encountered an error condition
2252 * subtype bit 14 - transmit FIFO underrun
2253 * subtype bit 15 - receive FIFO overrun
2255 case ISB_IMC_TRC_FIFO_STATUS
:
2256 if(isb_subtype
& TRC_FIFO_STATUS_TX_UNDERRUN
)
2258 if(tp
->ptr_tx_fifo_underruns
)
2259 (*tp
->ptr_tx_fifo_underruns
)++;
2262 if(isb_subtype
& TRC_FIFO_STATUS_RX_OVERRUN
)
2264 /* update overrun stuck receive counter
2265 * if >= 3, has to clear it by sending
2266 * back to back frames. We pick
2267 * DAT(duplicate address MAC frame)
2269 tp
->rx_fifo_overrun_count
++;
2271 if(tp
->rx_fifo_overrun_count
>= 3)
2273 tp
->rx_fifo_overrun_count
= 0;
2275 /* delay clearing fifo overrun
2276 * imask till send_BUG tx
2279 interrupt_unmask_bits
&= (~0x800);
2280 printk(KERN_CRIT
"Jay please send bug\n");// smctr_send_bug(dev);
2283 if(tp
->ptr_rx_fifo_overruns
)
2284 (*tp
->ptr_rx_fifo_overruns
)++;
2290 /* Type 0x0C - Action Command Status Interrupt
2291 * Subtype bit 14 - CB end of command chain (CE)
2292 * Subtype bit 15 - CB command interrupt (CI)
2294 case ISB_IMC_COMMAND_STATUS
:
2296 if(tp
->acb_head
->cmd
== ACB_CMD_HIC_NOP
)
2298 printk(KERN_ERR
"i1\n");
2299 smctr_disable_16bit(dev
);
2301 /* XXXXXXXXXXXXXXXXX */
2302 /* err = UM_Interrupt(dev); */
2304 smctr_enable_16bit(dev
);
2308 if((tp
->acb_head
->cmd
2309 == ACB_CMD_READ_TRC_STATUS
)
2310 && (tp
->acb_head
->subcmd
2311 == RW_TRC_STATUS_BLOCK
))
2313 if(tp
->ptr_bcn_type
!= 0)
2316 = (__u32
)((SBlock
*)tp
->misc_command_data
)->BCN_Type
;
2319 if(((SBlock
*)tp
->misc_command_data
)->Status_CHG_Indicate
& ERROR_COUNTERS_CHANGED
)
2321 smctr_update_err_stats(dev
);
2324 if(((SBlock
*)tp
->misc_command_data
)->Status_CHG_Indicate
& TI_NDIS_RING_STATUS_CHANGED
)
2327 = ((SBlock
*)tp
->misc_command_data
)->TI_NDIS_Ring_Status
;
2328 smctr_disable_16bit(dev
);
2329 err
= smctr_ring_status_chg(dev
);
2330 smctr_enable_16bit(dev
);
2331 if((tp
->ring_status
& REMOVE_RECEIVED
)
2332 && (tp
->config_word0
& NO_AUTOREMOVE
))
2334 smctr_issue_remove_cmd(dev
);
2339 tp
->acb_pending
= 0;
2344 if(((SBlock
*)tp
->misc_command_data
)->Status_CHG_Indicate
& UNA_CHANGED
)
2348 tp
->ptr_una
[0] = SWAP_BYTES(((SBlock
*)tp
->misc_command_data
)->UNA
[0]);
2349 tp
->ptr_una
[1] = SWAP_BYTES(((SBlock
*)tp
->misc_command_data
)->UNA
[1]);
2350 tp
->ptr_una
[2] = SWAP_BYTES(((SBlock
*)tp
->misc_command_data
)->UNA
[2]);
2355 if(((SBlock
*)tp
->misc_command_data
)->Status_CHG_Indicate
& READY_TO_SEND_RQ_INIT
) {
2356 err
= smctr_send_rq_init(dev
);
2361 tp
->acb_pending
= 0;
2364 /* Type 0x0D - MAC Type 1 interrupt
2365 * Subtype -- 00 FR_BCN received at S12
2366 * 01 FR_BCN received at S21
2367 * 02 FR_DAT(DA=MA, A<>0) received at S21
2369 * 04 FR_REMOVE received at S42
2370 * 05 TBR_EXP, BR_FLAG_SET at S42
2373 case ISB_IMC_MAC_TYPE_1
:
2376 err
= HARDWARE_FAILED
;
2384 tp
->join_state
= JS_BYPASS_STATE
;
2385 if(tp
->status
!= CLOSED
)
2387 tp
->status
= CLOSED
;
2388 err
= smctr_status_chg(dev
);
2393 tp
->join_state
= JS_LOBE_TEST_STATE
;
2397 tp
->join_state
= JS_DETECT_MONITOR_PRESENT_STATE
;
2401 tp
->join_state
= JS_AWAIT_NEW_MONITOR_STATE
;
2405 tp
->join_state
= JS_DUPLICATE_ADDRESS_TEST_STATE
;
2409 tp
->join_state
= JS_NEIGHBOR_NOTIFICATION_STATE
;
2413 tp
->join_state
= JS_REQUEST_INITIALIZATION_STATE
;
2417 tp
->join_state
= JS_JOIN_COMPLETE_STATE
;
2419 err
= smctr_status_chg(dev
);
2423 tp
->join_state
= JS_BYPASS_WAIT_STATE
;
2428 /* Type 0x0E - TRC Initialization Sequence Interrupt
2429 * Subtype -- 00-FF Initializatin sequence complete
2431 case ISB_IMC_TRC_INTRNL_TST_STATUS
:
2432 tp
->status
= INITIALIZED
;
2433 smctr_disable_16bit(dev
);
2434 err
= smctr_status_chg(dev
);
2435 smctr_enable_16bit(dev
);
2438 /* other interrupt types, illegal */
2447 /* Checking the ack code instead of the unmask bits here is because :
2448 * while fixing the stuck receive, DAT frame are sent and mask off
2449 * FIFO overrun interrupt temporarily (interrupt_unmask_bits = 0)
2450 * but we still want to issue ack to ISB
2452 if(!(interrupt_ack_code
& 0xff00))
2453 smctr_issue_int_ack(dev
, interrupt_ack_code
, interrupt_unmask_bits
);
2455 smctr_disable_16bit(dev
);
2456 smctr_enable_bic_int(dev
);
2457 spin_unlock(&tp
->lock
);
2462 static int smctr_issue_enable_int_cmd(struct net_device
*dev
,
2463 __u16 interrupt_enable_mask
)
2465 struct net_local
*tp
= netdev_priv(dev
);
2468 if((err
= smctr_wait_while_cbusy(dev
)))
2471 tp
->sclb_ptr
->int_mask_control
= interrupt_enable_mask
;
2472 tp
->sclb_ptr
->valid_command
= SCLB_VALID
| SCLB_CMD_CLEAR_INTERRUPT_MASK
;
2474 smctr_set_ctrl_attention(dev
);
2479 static int smctr_issue_int_ack(struct net_device
*dev
, __u16 iack_code
, __u16 ibits
)
2481 struct net_local
*tp
= netdev_priv(dev
);
2483 if(smctr_wait_while_cbusy(dev
))
2486 tp
->sclb_ptr
->int_mask_control
= ibits
;
2487 tp
->sclb_ptr
->iack_code
= iack_code
<< 1; /* use the offset from base */ tp
->sclb_ptr
->resume_control
= 0;
2488 tp
->sclb_ptr
->valid_command
= SCLB_VALID
| SCLB_IACK_CODE_VALID
| SCLB_CMD_CLEAR_INTERRUPT_MASK
;
2490 smctr_set_ctrl_attention(dev
);
2495 static int smctr_issue_init_timers_cmd(struct net_device
*dev
)
2497 struct net_local
*tp
= netdev_priv(dev
);
2500 __u16
*pTimer_Struc
= (__u16
*)tp
->misc_command_data
;
2502 if((err
= smctr_wait_while_cbusy(dev
)))
2505 if((err
= smctr_wait_cmd(dev
)))
2508 tp
->config_word0
= THDREN
| DMA_TRIGGER
| USETPT
| NO_AUTOREMOVE
;
2509 tp
->config_word1
= 0;
2511 if((tp
->media_type
== MEDIA_STP_16
)
2512 || (tp
->media_type
== MEDIA_UTP_16
)
2513 || (tp
->media_type
== MEDIA_STP_16_UTP_16
))
2515 tp
->config_word0
|= FREQ_16MB_BIT
;
2518 if(tp
->mode_bits
& EARLY_TOKEN_REL
)
2519 tp
->config_word0
|= ETREN
;
2521 if(tp
->mode_bits
& LOOPING_MODE_MASK
)
2522 tp
->config_word0
|= RX_OWN_BIT
;
2524 tp
->config_word0
&= ~RX_OWN_BIT
;
2526 if(tp
->receive_mask
& PROMISCUOUS_MODE
)
2527 tp
->config_word0
|= PROMISCUOUS_BIT
;
2529 tp
->config_word0
&= ~PROMISCUOUS_BIT
;
2531 if(tp
->receive_mask
& ACCEPT_ERR_PACKETS
)
2532 tp
->config_word0
|= SAVBAD_BIT
;
2534 tp
->config_word0
&= ~SAVBAD_BIT
;
2536 if(tp
->receive_mask
& ACCEPT_ATT_MAC_FRAMES
)
2537 tp
->config_word0
|= RXATMAC
;
2539 tp
->config_word0
&= ~RXATMAC
;
2541 if(tp
->receive_mask
& ACCEPT_MULTI_PROM
)
2542 tp
->config_word1
|= MULTICAST_ADDRESS_BIT
;
2544 tp
->config_word1
&= ~MULTICAST_ADDRESS_BIT
;
2546 if(tp
->receive_mask
& ACCEPT_SOURCE_ROUTING_SPANNING
)
2547 tp
->config_word1
|= SOURCE_ROUTING_SPANNING_BITS
;
2550 if(tp
->receive_mask
& ACCEPT_SOURCE_ROUTING
)
2551 tp
->config_word1
|= SOURCE_ROUTING_EXPLORER_BIT
;
2553 tp
->config_word1
&= ~SOURCE_ROUTING_SPANNING_BITS
;
2556 if((tp
->media_type
== MEDIA_STP_16
)
2557 || (tp
->media_type
== MEDIA_UTP_16
)
2558 || (tp
->media_type
== MEDIA_STP_16_UTP_16
))
2560 tp
->config_word1
|= INTERFRAME_SPACING_16
;
2563 tp
->config_word1
|= INTERFRAME_SPACING_4
;
2565 *pTimer_Struc
++ = tp
->config_word0
;
2566 *pTimer_Struc
++ = tp
->config_word1
;
2568 if((tp
->media_type
== MEDIA_STP_4
)
2569 || (tp
->media_type
== MEDIA_UTP_4
)
2570 || (tp
->media_type
== MEDIA_STP_4_UTP_4
))
2572 *pTimer_Struc
++ = 0x00FA; /* prescale */
2573 *pTimer_Struc
++ = 0x2710; /* TPT_limit */
2574 *pTimer_Struc
++ = 0x2710; /* TQP_limit */
2575 *pTimer_Struc
++ = 0x0A28; /* TNT_limit */
2576 *pTimer_Struc
++ = 0x3E80; /* TBT_limit */
2577 *pTimer_Struc
++ = 0x3A98; /* TSM_limit */
2578 *pTimer_Struc
++ = 0x1B58; /* TAM_limit */
2579 *pTimer_Struc
++ = 0x00C8; /* TBR_limit */
2580 *pTimer_Struc
++ = 0x07D0; /* TER_limit */
2581 *pTimer_Struc
++ = 0x000A; /* TGT_limit */
2582 *pTimer_Struc
++ = 0x1162; /* THT_limit */
2583 *pTimer_Struc
++ = 0x07D0; /* TRR_limit */
2584 *pTimer_Struc
++ = 0x1388; /* TVX_limit */
2585 *pTimer_Struc
++ = 0x0000; /* reserved */
2589 *pTimer_Struc
++ = 0x03E8; /* prescale */
2590 *pTimer_Struc
++ = 0x9C40; /* TPT_limit */
2591 *pTimer_Struc
++ = 0x9C40; /* TQP_limit */
2592 *pTimer_Struc
++ = 0x0A28; /* TNT_limit */
2593 *pTimer_Struc
++ = 0x3E80; /* TBT_limit */
2594 *pTimer_Struc
++ = 0x3A98; /* TSM_limit */
2595 *pTimer_Struc
++ = 0x1B58; /* TAM_limit */
2596 *pTimer_Struc
++ = 0x00C8; /* TBR_limit */
2597 *pTimer_Struc
++ = 0x07D0; /* TER_limit */
2598 *pTimer_Struc
++ = 0x000A; /* TGT_limit */
2599 *pTimer_Struc
++ = 0x4588; /* THT_limit */
2600 *pTimer_Struc
++ = 0x1F40; /* TRR_limit */
2601 *pTimer_Struc
++ = 0x4E20; /* TVX_limit */
2602 *pTimer_Struc
++ = 0x0000; /* reserved */
2605 /* Set node address. */
2606 *pTimer_Struc
++ = dev
->dev_addr
[0] << 8
2607 | (dev
->dev_addr
[1] & 0xFF);
2608 *pTimer_Struc
++ = dev
->dev_addr
[2] << 8
2609 | (dev
->dev_addr
[3] & 0xFF);
2610 *pTimer_Struc
++ = dev
->dev_addr
[4] << 8
2611 | (dev
->dev_addr
[5] & 0xFF);
2613 /* Set group address. */
2614 *pTimer_Struc
++ = tp
->group_address_0
<< 8
2615 | tp
->group_address_0
>> 8;
2616 *pTimer_Struc
++ = tp
->group_address
[0] << 8
2617 | tp
->group_address
[0] >> 8;
2618 *pTimer_Struc
++ = tp
->group_address
[1] << 8
2619 | tp
->group_address
[1] >> 8;
2621 /* Set functional address. */
2622 *pTimer_Struc
++ = tp
->functional_address_0
<< 8
2623 | tp
->functional_address_0
>> 8;
2624 *pTimer_Struc
++ = tp
->functional_address
[0] << 8
2625 | tp
->functional_address
[0] >> 8;
2626 *pTimer_Struc
++ = tp
->functional_address
[1] << 8
2627 | tp
->functional_address
[1] >> 8;
2629 /* Set Bit-Wise group address. */
2630 *pTimer_Struc
++ = tp
->bitwise_group_address
[0] << 8
2631 | tp
->bitwise_group_address
[0] >> 8;
2632 *pTimer_Struc
++ = tp
->bitwise_group_address
[1] << 8
2633 | tp
->bitwise_group_address
[1] >> 8;
2635 /* Set ring number address. */
2636 *pTimer_Struc
++ = tp
->source_ring_number
;
2637 *pTimer_Struc
++ = tp
->target_ring_number
;
2639 /* Physical drop number. */
2640 *pTimer_Struc
++ = (unsigned short)0;
2641 *pTimer_Struc
++ = (unsigned short)0;
2643 /* Product instance ID. */
2644 for(i
= 0; i
< 9; i
++)
2645 *pTimer_Struc
++ = (unsigned short)0;
2647 err
= smctr_setup_single_cmd_w_data(dev
, ACB_CMD_INIT_TRC_TIMERS
, 0);
2652 static int smctr_issue_init_txrx_cmd(struct net_device
*dev
)
2654 struct net_local
*tp
= netdev_priv(dev
);
2657 void **txrx_ptrs
= (void *)tp
->misc_command_data
;
2659 if((err
= smctr_wait_while_cbusy(dev
)))
2662 if((err
= smctr_wait_cmd(dev
)))
2664 printk(KERN_ERR
"%s: Hardware failure\n", dev
->name
);
2668 /* Initialize Transmit Queue Pointers that are used, to point to
2671 for(i
= 0; i
< NUM_TX_QS_USED
; i
++)
2672 *txrx_ptrs
++ = (void *)TRC_POINTER(tp
->tx_fcb_head
[i
]);
2674 /* Initialize Transmit Queue Pointers that are NOT used to ZERO. */
2675 for(; i
< MAX_TX_QS
; i
++)
2676 *txrx_ptrs
++ = (void *)0;
2678 /* Initialize Receive Queue Pointers (MAC and Non-MAC) that are
2679 * used, to point to a single FCB and a BDB chain of buffers.
2681 for(i
= 0; i
< NUM_RX_QS_USED
; i
++)
2683 *txrx_ptrs
++ = (void *)TRC_POINTER(tp
->rx_fcb_head
[i
]);
2684 *txrx_ptrs
++ = (void *)TRC_POINTER(tp
->rx_bdb_head
[i
]);
2687 /* Initialize Receive Queue Pointers that are NOT used to ZERO. */
2688 for(; i
< MAX_RX_QS
; i
++)
2690 *txrx_ptrs
++ = (void *)0;
2691 *txrx_ptrs
++ = (void *)0;
2694 err
= smctr_setup_single_cmd_w_data(dev
, ACB_CMD_INIT_TX_RX
, 0);
2699 static int smctr_issue_insert_cmd(struct net_device
*dev
)
2703 err
= smctr_setup_single_cmd(dev
, ACB_CMD_INSERT
, ACB_SUB_CMD_NOP
);
2708 static int smctr_issue_read_ring_status_cmd(struct net_device
*dev
)
2712 if((err
= smctr_wait_while_cbusy(dev
)))
2715 if((err
= smctr_wait_cmd(dev
)))
2718 err
= smctr_setup_single_cmd_w_data(dev
, ACB_CMD_READ_TRC_STATUS
,
2719 RW_TRC_STATUS_BLOCK
);
2724 static int smctr_issue_read_word_cmd(struct net_device
*dev
, __u16 aword_cnt
)
2728 if((err
= smctr_wait_while_cbusy(dev
)))
2731 if((err
= smctr_wait_cmd(dev
)))
2734 err
= smctr_setup_single_cmd_w_data(dev
, ACB_CMD_MCT_READ_VALUE
,
2740 static int smctr_issue_remove_cmd(struct net_device
*dev
)
2742 struct net_local
*tp
= netdev_priv(dev
);
2745 if((err
= smctr_wait_while_cbusy(dev
)))
2748 tp
->sclb_ptr
->resume_control
= 0;
2749 tp
->sclb_ptr
->valid_command
= SCLB_VALID
| SCLB_CMD_REMOVE
;
2751 smctr_set_ctrl_attention(dev
);
2756 static int smctr_issue_resume_acb_cmd(struct net_device
*dev
)
2758 struct net_local
*tp
= netdev_priv(dev
);
2761 if((err
= smctr_wait_while_cbusy(dev
)))
2764 tp
->sclb_ptr
->resume_control
= SCLB_RC_ACB
;
2765 tp
->sclb_ptr
->valid_command
= SCLB_VALID
| SCLB_RESUME_CONTROL_VALID
;
2767 tp
->acb_pending
= 1;
2769 smctr_set_ctrl_attention(dev
);
2774 static int smctr_issue_resume_rx_bdb_cmd(struct net_device
*dev
, __u16 queue
)
2776 struct net_local
*tp
= netdev_priv(dev
);
2779 if((err
= smctr_wait_while_cbusy(dev
)))
2782 if(queue
== MAC_QUEUE
)
2783 tp
->sclb_ptr
->resume_control
= SCLB_RC_RX_MAC_BDB
;
2785 tp
->sclb_ptr
->resume_control
= SCLB_RC_RX_NON_MAC_BDB
;
2787 tp
->sclb_ptr
->valid_command
= SCLB_VALID
| SCLB_RESUME_CONTROL_VALID
;
2789 smctr_set_ctrl_attention(dev
);
2794 static int smctr_issue_resume_rx_fcb_cmd(struct net_device
*dev
, __u16 queue
)
2796 struct net_local
*tp
= netdev_priv(dev
);
2798 if(smctr_debug
> 10)
2799 printk(KERN_DEBUG
"%s: smctr_issue_resume_rx_fcb_cmd\n", dev
->name
);
2801 if(smctr_wait_while_cbusy(dev
))
2804 if(queue
== MAC_QUEUE
)
2805 tp
->sclb_ptr
->resume_control
= SCLB_RC_RX_MAC_FCB
;
2807 tp
->sclb_ptr
->resume_control
= SCLB_RC_RX_NON_MAC_FCB
;
2809 tp
->sclb_ptr
->valid_command
= SCLB_VALID
| SCLB_RESUME_CONTROL_VALID
;
2811 smctr_set_ctrl_attention(dev
);
2816 static int smctr_issue_resume_tx_fcb_cmd(struct net_device
*dev
, __u16 queue
)
2818 struct net_local
*tp
= netdev_priv(dev
);
2820 if(smctr_debug
> 10)
2821 printk(KERN_DEBUG
"%s: smctr_issue_resume_tx_fcb_cmd\n", dev
->name
);
2823 if(smctr_wait_while_cbusy(dev
))
2826 tp
->sclb_ptr
->resume_control
= (SCLB_RC_TFCB0
<< queue
);
2827 tp
->sclb_ptr
->valid_command
= SCLB_RESUME_CONTROL_VALID
| SCLB_VALID
;
2829 smctr_set_ctrl_attention(dev
);
2834 static int smctr_issue_test_internal_rom_cmd(struct net_device
*dev
)
2838 err
= smctr_setup_single_cmd(dev
, ACB_CMD_MCT_TEST
,
2839 TRC_INTERNAL_ROM_TEST
);
2844 static int smctr_issue_test_hic_cmd(struct net_device
*dev
)
2848 err
= smctr_setup_single_cmd(dev
, ACB_CMD_HIC_TEST
,
2849 TRC_HOST_INTERFACE_REG_TEST
);
2854 static int smctr_issue_test_mac_reg_cmd(struct net_device
*dev
)
2858 err
= smctr_setup_single_cmd(dev
, ACB_CMD_MCT_TEST
,
2859 TRC_MAC_REGISTERS_TEST
);
2864 static int smctr_issue_trc_loopback_cmd(struct net_device
*dev
)
2868 err
= smctr_setup_single_cmd(dev
, ACB_CMD_MCT_TEST
,
2869 TRC_INTERNAL_LOOPBACK
);
2874 static int smctr_issue_tri_loopback_cmd(struct net_device
*dev
)
2878 err
= smctr_setup_single_cmd(dev
, ACB_CMD_MCT_TEST
,
2884 static int smctr_issue_write_byte_cmd(struct net_device
*dev
,
2885 short aword_cnt
, void *byte
)
2887 struct net_local
*tp
= netdev_priv(dev
);
2888 unsigned int iword
, ibyte
;
2891 if((err
= smctr_wait_while_cbusy(dev
)))
2894 if((err
= smctr_wait_cmd(dev
)))
2897 for(iword
= 0, ibyte
= 0; iword
< (unsigned int)(aword_cnt
& 0xff);
2898 iword
++, ibyte
+= 2)
2900 tp
->misc_command_data
[iword
] = (*((__u8
*)byte
+ ibyte
) << 8)
2901 | (*((__u8
*)byte
+ ibyte
+ 1));
2904 return (smctr_setup_single_cmd_w_data(dev
, ACB_CMD_MCT_WRITE_VALUE
,
2908 static int smctr_issue_write_word_cmd(struct net_device
*dev
,
2909 short aword_cnt
, void *word
)
2911 struct net_local
*tp
= netdev_priv(dev
);
2912 unsigned int i
, err
;
2914 if((err
= smctr_wait_while_cbusy(dev
)))
2917 if((err
= smctr_wait_cmd(dev
)))
2920 for(i
= 0; i
< (unsigned int)(aword_cnt
& 0xff); i
++)
2921 tp
->misc_command_data
[i
] = *((__u16
*)word
+ i
);
2923 err
= smctr_setup_single_cmd_w_data(dev
, ACB_CMD_MCT_WRITE_VALUE
,
2929 static int smctr_join_complete_state(struct net_device
*dev
)
2933 err
= smctr_setup_single_cmd(dev
, ACB_CMD_CHANGE_JOIN_STATE
,
2934 JS_JOIN_COMPLETE_STATE
);
2939 static int smctr_link_tx_fcbs_to_bdbs(struct net_device
*dev
)
2941 struct net_local
*tp
= netdev_priv(dev
);
2946 for(i
= 0; i
< NUM_TX_QS_USED
; i
++)
2948 fcb
= tp
->tx_fcb_head
[i
];
2949 bdb
= tp
->tx_bdb_head
[i
];
2951 for(j
= 0; j
< tp
->num_tx_fcbs
[i
]; j
++)
2954 fcb
->trc_bdb_ptr
= TRC_POINTER(bdb
);
2955 fcb
= (FCBlock
*)((char *)fcb
+ sizeof(FCBlock
));
2956 bdb
= (BDBlock
*)((char *)bdb
+ sizeof(BDBlock
));
2963 static int smctr_load_firmware(struct net_device
*dev
)
2965 struct net_local
*tp
= netdev_priv(dev
);
2966 __u16 i
, checksum
= 0;
2969 if(smctr_debug
> 10)
2970 printk(KERN_DEBUG
"%s: smctr_load_firmware\n", dev
->name
);
2972 tp
->ptr_ucode
= smctr_code
;
2973 tp
->num_of_tx_buffs
= 4;
2974 tp
->mode_bits
|= UMAC
;
2975 tp
->receive_mask
= 0;
2976 tp
->max_packet_size
= 4177;
2978 /* Can only upload the firmware once per adapter reset. */
2979 if(tp
->microcode_version
!= 0)
2980 return (UCODE_PRESENT
);
2982 /* Verify the firmware exists and is there in the right amount. */
2983 if((tp
->ptr_ucode
== 0L)
2984 || (*(tp
->ptr_ucode
+ UCODE_VERSION_OFFSET
) < UCODE_VERSION
))
2986 return (UCODE_NOT_PRESENT
);
2989 /* UCODE_SIZE is not included in Checksum. */
2990 for(i
= 0; i
< *((__u16
*)(tp
->ptr_ucode
+ UCODE_SIZE_OFFSET
)); i
+= 2)
2991 checksum
+= *((__u16
*)(tp
->ptr_ucode
+ 2 + i
));
2993 return (UCODE_NOT_PRESENT
);
2995 /* At this point we have a valid firmware image, lets kick it on up. */
2996 smctr_enable_adapter_ram(dev
);
2997 smctr_enable_16bit(dev
);
2998 smctr_set_page(dev
, (__u8
*)tp
->ram_access
);
3000 if((smctr_checksum_firmware(dev
))
3001 || (*(tp
->ptr_ucode
+ UCODE_VERSION_OFFSET
)
3002 > tp
->microcode_version
))
3004 smctr_enable_adapter_ctrl_store(dev
);
3006 /* Zero out ram space for firmware. */
3007 for(i
= 0; i
< CS_RAM_SIZE
; i
+= 2)
3008 *((__u16
*)(tp
->ram_access
+ i
)) = 0;
3010 smctr_decode_firmware(dev
);
3012 tp
->microcode_version
= *(tp
->ptr_ucode
+ UCODE_VERSION_OFFSET
); *((__u16
*)(tp
->ram_access
+ CS_RAM_VERSION_OFFSET
))
3013 = (tp
->microcode_version
<< 8);
3014 *((__u16
*)(tp
->ram_access
+ CS_RAM_CHECKSUM_OFFSET
))
3015 = ~(tp
->microcode_version
<< 8) + 1;
3017 smctr_disable_adapter_ctrl_store(dev
);
3019 if(smctr_checksum_firmware(dev
))
3020 err
= HARDWARE_FAILED
;
3023 err
= UCODE_PRESENT
;
3025 smctr_disable_16bit(dev
);
3030 static int smctr_load_node_addr(struct net_device
*dev
)
3032 int ioaddr
= dev
->base_addr
;
3036 for(i
= 0; i
< 6; i
++)
3038 r
= inb(ioaddr
+ LAR0
+ i
);
3039 dev
->dev_addr
[i
] = (char)r
;
3047 * During the transmission of the initial 1500 lobe media MAC frames,
3048 * the phase lock loop in the 805 chip may lock, and then un-lock, causing
3049 * the 825 to go into a PURGE state. When performing a PURGE, the MCT
3050 * microcode will not transmit any frames given to it by the host, and
3051 * will consequently cause a timeout.
3053 * NOTE 1: If the monitor_state is MS_BEACON_TEST_STATE, all transmit
3054 * queues other then the one used for the lobe_media_test should be
3057 * NOTE 2: If the monitor_state is MS_BEACON_TEST_STATE and the receive_mask
3058 * has any multi-cast or promiscous bits set, the receive_mask needs to
3059 * be changed to clear the multi-cast or promiscous mode bits, the lobe_test
3060 * run, and then the receive mask set back to its original value if the test
3063 static int smctr_lobe_media_test(struct net_device
*dev
)
3065 struct net_local
*tp
= netdev_priv(dev
);
3066 unsigned int i
, perror
= 0;
3067 unsigned short saved_rcv_mask
;
3069 if(smctr_debug
> 10)
3070 printk(KERN_DEBUG
"%s: smctr_lobe_media_test\n", dev
->name
);
3072 /* Clear receive mask for lobe test. */
3073 saved_rcv_mask
= tp
->receive_mask
;
3074 tp
->receive_mask
= 0;
3076 smctr_chg_rx_mask(dev
);
3078 /* Setup the lobe media test. */
3079 smctr_lobe_media_test_cmd(dev
);
3080 if(smctr_wait_cmd(dev
))
3082 smctr_reset_adapter(dev
);
3083 tp
->status
= CLOSED
;
3084 return (LOBE_MEDIA_TEST_FAILED
);
3087 /* Tx lobe media test frames. */
3088 for(i
= 0; i
< 1500; ++i
)
3090 if(smctr_send_lobe_media_test(dev
))
3094 smctr_reset_adapter(dev
);
3096 return (LOBE_MEDIA_TEST_FAILED
);
3101 if(smctr_lobe_media_test_cmd(dev
))
3103 smctr_reset_adapter(dev
);
3105 return (LOBE_MEDIA_TEST_FAILED
);
3111 if(smctr_send_dat(dev
))
3113 if(smctr_send_dat(dev
))
3115 smctr_reset_adapter(dev
);
3117 return (LOBE_MEDIA_TEST_FAILED
);
3121 /* Check if any frames received during test. */
3122 if((tp
->rx_fcb_curr
[MAC_QUEUE
]->frame_status
)
3123 || (tp
->rx_fcb_curr
[NON_MAC_QUEUE
]->frame_status
))
3125 smctr_reset_adapter(dev
);
3127 return (LOBE_MEDIA_TEST_FAILED
);
3130 /* Set receive mask to "Promisc" mode. */
3131 tp
->receive_mask
= saved_rcv_mask
;
3133 smctr_chg_rx_mask(dev
);
3138 static int smctr_lobe_media_test_cmd(struct net_device
*dev
)
3140 struct net_local
*tp
= netdev_priv(dev
);
3143 if(smctr_debug
> 10)
3144 printk(KERN_DEBUG
"%s: smctr_lobe_media_test_cmd\n", dev
->name
);
3146 /* Change to lobe media test state. */
3147 if(tp
->monitor_state
!= MS_BEACON_TEST_STATE
)
3149 smctr_lobe_media_test_state(dev
);
3150 if(smctr_wait_cmd(dev
))
3152 printk(KERN_ERR
"Lobe Failed test state\n");
3153 return (LOBE_MEDIA_TEST_FAILED
);
3157 err
= smctr_setup_single_cmd(dev
, ACB_CMD_MCT_TEST
,
3158 TRC_LOBE_MEDIA_TEST
);
3163 static int smctr_lobe_media_test_state(struct net_device
*dev
)
3167 err
= smctr_setup_single_cmd(dev
, ACB_CMD_CHANGE_JOIN_STATE
,
3168 JS_LOBE_TEST_STATE
);
3173 static int smctr_make_8025_hdr(struct net_device
*dev
,
3174 MAC_HEADER
*rmf
, MAC_HEADER
*tmf
, __u16 ac_fc
)
3176 tmf
->ac
= MSB(ac_fc
); /* msb is access control */
3177 tmf
->fc
= LSB(ac_fc
); /* lsb is frame control */
3179 tmf
->sa
[0] = dev
->dev_addr
[0];
3180 tmf
->sa
[1] = dev
->dev_addr
[1];
3181 tmf
->sa
[2] = dev
->dev_addr
[2];
3182 tmf
->sa
[3] = dev
->dev_addr
[3];
3183 tmf
->sa
[4] = dev
->dev_addr
[4];
3184 tmf
->sa
[5] = dev
->dev_addr
[5];
3188 /* Send RQ_INIT to RPS */
3198 /* Send RPT_TX_FORWARD to CRS */
3199 case RPT_TX_FORWARD
:
3208 /* Everything else goes to sender */
3210 tmf
->da
[0] = rmf
->sa
[0];
3211 tmf
->da
[1] = rmf
->sa
[1];
3212 tmf
->da
[2] = rmf
->sa
[2];
3213 tmf
->da
[3] = rmf
->sa
[3];
3214 tmf
->da
[4] = rmf
->sa
[4];
3215 tmf
->da
[5] = rmf
->sa
[5];
3222 static int smctr_make_access_pri(struct net_device
*dev
, MAC_SUB_VECTOR
*tsv
)
3224 struct net_local
*tp
= netdev_priv(dev
);
3226 tsv
->svi
= AUTHORIZED_ACCESS_PRIORITY
;
3227 tsv
->svl
= S_AUTHORIZED_ACCESS_PRIORITY
;
3229 tsv
->svv
[0] = MSB(tp
->authorized_access_priority
);
3230 tsv
->svv
[1] = LSB(tp
->authorized_access_priority
);
3235 static int smctr_make_addr_mod(struct net_device
*dev
, MAC_SUB_VECTOR
*tsv
)
3237 tsv
->svi
= ADDRESS_MODIFER
;
3238 tsv
->svl
= S_ADDRESS_MODIFER
;
3246 static int smctr_make_auth_funct_class(struct net_device
*dev
,
3247 MAC_SUB_VECTOR
*tsv
)
3249 struct net_local
*tp
= netdev_priv(dev
);
3251 tsv
->svi
= AUTHORIZED_FUNCTION_CLASS
;
3252 tsv
->svl
= S_AUTHORIZED_FUNCTION_CLASS
;
3254 tsv
->svv
[0] = MSB(tp
->authorized_function_classes
);
3255 tsv
->svv
[1] = LSB(tp
->authorized_function_classes
);
3260 static int smctr_make_corr(struct net_device
*dev
,
3261 MAC_SUB_VECTOR
*tsv
, __u16 correlator
)
3263 tsv
->svi
= CORRELATOR
;
3264 tsv
->svl
= S_CORRELATOR
;
3266 tsv
->svv
[0] = MSB(correlator
);
3267 tsv
->svv
[1] = LSB(correlator
);
3272 static int smctr_make_funct_addr(struct net_device
*dev
, MAC_SUB_VECTOR
*tsv
)
3274 struct net_local
*tp
= netdev_priv(dev
);
3276 smctr_get_functional_address(dev
);
3278 tsv
->svi
= FUNCTIONAL_ADDRESS
;
3279 tsv
->svl
= S_FUNCTIONAL_ADDRESS
;
3281 tsv
->svv
[0] = MSB(tp
->misc_command_data
[0]);
3282 tsv
->svv
[1] = LSB(tp
->misc_command_data
[0]);
3284 tsv
->svv
[2] = MSB(tp
->misc_command_data
[1]);
3285 tsv
->svv
[3] = LSB(tp
->misc_command_data
[1]);
3290 static int smctr_make_group_addr(struct net_device
*dev
, MAC_SUB_VECTOR
*tsv
)
3292 struct net_local
*tp
= netdev_priv(dev
);
3294 smctr_get_group_address(dev
);
3296 tsv
->svi
= GROUP_ADDRESS
;
3297 tsv
->svl
= S_GROUP_ADDRESS
;
3299 tsv
->svv
[0] = MSB(tp
->misc_command_data
[0]);
3300 tsv
->svv
[1] = LSB(tp
->misc_command_data
[0]);
3302 tsv
->svv
[2] = MSB(tp
->misc_command_data
[1]);
3303 tsv
->svv
[3] = LSB(tp
->misc_command_data
[1]);
3305 /* Set Group Address Sub-vector to all zeros if only the
3306 * Group Address/Functional Address Indicator is set.
3308 if(tsv
->svv
[0] == 0x80 && tsv
->svv
[1] == 0x00
3309 && tsv
->svv
[2] == 0x00 && tsv
->svv
[3] == 0x00)
3315 static int smctr_make_phy_drop_num(struct net_device
*dev
,
3316 MAC_SUB_VECTOR
*tsv
)
3318 struct net_local
*tp
= netdev_priv(dev
);
3320 smctr_get_physical_drop_number(dev
);
3322 tsv
->svi
= PHYSICAL_DROP
;
3323 tsv
->svl
= S_PHYSICAL_DROP
;
3325 tsv
->svv
[0] = MSB(tp
->misc_command_data
[0]);
3326 tsv
->svv
[1] = LSB(tp
->misc_command_data
[0]);
3328 tsv
->svv
[2] = MSB(tp
->misc_command_data
[1]);
3329 tsv
->svv
[3] = LSB(tp
->misc_command_data
[1]);
3334 static int smctr_make_product_id(struct net_device
*dev
, MAC_SUB_VECTOR
*tsv
)
3338 tsv
->svi
= PRODUCT_INSTANCE_ID
;
3339 tsv
->svl
= S_PRODUCT_INSTANCE_ID
;
3341 for(i
= 0; i
< 18; i
++)
3347 static int smctr_make_station_id(struct net_device
*dev
, MAC_SUB_VECTOR
*tsv
)
3349 struct net_local
*tp
= netdev_priv(dev
);
3351 smctr_get_station_id(dev
);
3353 tsv
->svi
= STATION_IDENTIFER
;
3354 tsv
->svl
= S_STATION_IDENTIFER
;
3356 tsv
->svv
[0] = MSB(tp
->misc_command_data
[0]);
3357 tsv
->svv
[1] = LSB(tp
->misc_command_data
[0]);
3359 tsv
->svv
[2] = MSB(tp
->misc_command_data
[1]);
3360 tsv
->svv
[3] = LSB(tp
->misc_command_data
[1]);
3362 tsv
->svv
[4] = MSB(tp
->misc_command_data
[2]);
3363 tsv
->svv
[5] = LSB(tp
->misc_command_data
[2]);
3368 static int smctr_make_ring_station_status(struct net_device
*dev
,
3369 MAC_SUB_VECTOR
* tsv
)
3371 tsv
->svi
= RING_STATION_STATUS
;
3372 tsv
->svl
= S_RING_STATION_STATUS
;
3384 static int smctr_make_ring_station_version(struct net_device
*dev
,
3385 MAC_SUB_VECTOR
*tsv
)
3387 struct net_local
*tp
= netdev_priv(dev
);
3389 tsv
->svi
= RING_STATION_VERSION_NUMBER
;
3390 tsv
->svl
= S_RING_STATION_VERSION_NUMBER
;
3392 tsv
->svv
[0] = 0xe2; /* EBCDIC - S */
3393 tsv
->svv
[1] = 0xd4; /* EBCDIC - M */
3394 tsv
->svv
[2] = 0xc3; /* EBCDIC - C */
3395 tsv
->svv
[3] = 0x40; /* EBCDIC - */
3396 tsv
->svv
[4] = 0xe5; /* EBCDIC - V */
3397 tsv
->svv
[5] = 0xF0 + (tp
->microcode_version
>> 4);
3398 tsv
->svv
[6] = 0xF0 + (tp
->microcode_version
& 0x0f);
3399 tsv
->svv
[7] = 0x40; /* EBCDIC - */
3400 tsv
->svv
[8] = 0xe7; /* EBCDIC - X */
3402 if(tp
->extra_info
& CHIP_REV_MASK
)
3403 tsv
->svv
[9] = 0xc5; /* EBCDIC - E */
3405 tsv
->svv
[9] = 0xc4; /* EBCDIC - D */
3410 static int smctr_make_tx_status_code(struct net_device
*dev
,
3411 MAC_SUB_VECTOR
*tsv
, __u16 tx_fstatus
)
3413 tsv
->svi
= TRANSMIT_STATUS_CODE
;
3414 tsv
->svl
= S_TRANSMIT_STATUS_CODE
;
3416 tsv
->svv
[0] = ((tx_fstatus
& 0x0100 >> 6) || IBM_PASS_SOURCE_ADDR
);
3418 /* Stripped frame status of Transmitted Frame */
3419 tsv
->svv
[1] = tx_fstatus
& 0xff;
3424 static int smctr_make_upstream_neighbor_addr(struct net_device
*dev
,
3425 MAC_SUB_VECTOR
*tsv
)
3427 struct net_local
*tp
= netdev_priv(dev
);
3429 smctr_get_upstream_neighbor_addr(dev
);
3431 tsv
->svi
= UPSTREAM_NEIGHBOR_ADDRESS
;
3432 tsv
->svl
= S_UPSTREAM_NEIGHBOR_ADDRESS
;
3434 tsv
->svv
[0] = MSB(tp
->misc_command_data
[0]);
3435 tsv
->svv
[1] = LSB(tp
->misc_command_data
[0]);
3437 tsv
->svv
[2] = MSB(tp
->misc_command_data
[1]);
3438 tsv
->svv
[3] = LSB(tp
->misc_command_data
[1]);
3440 tsv
->svv
[4] = MSB(tp
->misc_command_data
[2]);
3441 tsv
->svv
[5] = LSB(tp
->misc_command_data
[2]);
3446 static int smctr_make_wrap_data(struct net_device
*dev
, MAC_SUB_VECTOR
*tsv
)
3448 tsv
->svi
= WRAP_DATA
;
3449 tsv
->svl
= S_WRAP_DATA
;
3455 * Open/initialize the board. This is called sometime after
3456 * booting when the 'ifconfig' program is run.
3458 * This routine should set everything up anew at each open, even
3459 * registers that "should" only need to be set once at boot, so that
3460 * there is non-reboot way to recover if something goes wrong.
3462 static int smctr_open(struct net_device
*dev
)
3466 if(smctr_debug
> 10)
3467 printk(KERN_DEBUG
"%s: smctr_open\n", dev
->name
);
3469 err
= smctr_init_adapter(dev
);
3476 /* Interrupt driven open of Token card. */
3477 static int smctr_open_tr(struct net_device
*dev
)
3479 struct net_local
*tp
= netdev_priv(dev
);
3480 unsigned long flags
;
3483 if(smctr_debug
> 10)
3484 printk(KERN_DEBUG
"%s: smctr_open_tr\n", dev
->name
);
3486 /* Now we can actually open the adapter. */
3487 if(tp
->status
== OPEN
)
3489 if(tp
->status
!= INITIALIZED
)
3492 /* FIXME: it would work a lot better if we masked the irq sources
3493 on the card here, then we could skip the locking and poll nicely */
3494 spin_lock_irqsave(&tp
->lock
, flags
);
3496 smctr_set_page(dev
, (__u8
*)tp
->ram_access
);
3498 if((err
= smctr_issue_resume_rx_fcb_cmd(dev
, (short)MAC_QUEUE
)))
3501 if((err
= smctr_issue_resume_rx_bdb_cmd(dev
, (short)MAC_QUEUE
)))
3504 if((err
= smctr_issue_resume_rx_fcb_cmd(dev
, (short)NON_MAC_QUEUE
)))
3507 if((err
= smctr_issue_resume_rx_bdb_cmd(dev
, (short)NON_MAC_QUEUE
)))
3510 tp
->status
= CLOSED
;
3512 /* Insert into the Ring or Enter Loopback Mode. */
3513 if((tp
->mode_bits
& LOOPING_MODE_MASK
) == LOOPBACK_MODE_1
)
3515 tp
->status
= CLOSED
;
3517 if(!(err
= smctr_issue_trc_loopback_cmd(dev
)))
3519 if(!(err
= smctr_wait_cmd(dev
)))
3523 smctr_status_chg(dev
);
3527 if((tp
->mode_bits
& LOOPING_MODE_MASK
) == LOOPBACK_MODE_2
)
3529 tp
->status
= CLOSED
;
3530 if(!(err
= smctr_issue_tri_loopback_cmd(dev
)))
3532 if(!(err
= smctr_wait_cmd(dev
)))
3536 smctr_status_chg(dev
);
3540 if((tp
->mode_bits
& LOOPING_MODE_MASK
)
3543 tp
->status
= CLOSED
;
3544 if(!(err
= smctr_lobe_media_test_cmd(dev
)))
3546 if(!(err
= smctr_wait_cmd(dev
)))
3549 smctr_status_chg(dev
);
3553 if(!(err
= smctr_lobe_media_test(dev
)))
3554 err
= smctr_issue_insert_cmd(dev
);
3557 if(err
== LOBE_MEDIA_TEST_FAILED
)
3558 printk(KERN_WARNING
"%s: Lobe Media Test Failure - Check cable?\n", dev
->name
);
3565 spin_unlock_irqrestore(&tp
->lock
, flags
);
3570 /* Check for a network adapter of this type,
3571 * and return device structure if one exists.
3573 struct net_device __init
*smctr_probe(int unit
)
3575 struct net_device
*dev
= alloc_trdev(sizeof(struct net_local
));
3576 static const unsigned ports
[] = {
3577 0x200, 0x220, 0x240, 0x260, 0x280, 0x2A0, 0x2C0, 0x2E0, 0x300,
3578 0x320, 0x340, 0x360, 0x380, 0
3580 const unsigned *port
;
3584 return ERR_PTR(-ENOMEM
);
3587 sprintf(dev
->name
, "tr%d", unit
);
3588 netdev_boot_setup_check(dev
);
3591 if (dev
->base_addr
> 0x1ff) /* Check a single specified location. */
3592 err
= smctr_probe1(dev
, dev
->base_addr
);
3593 else if(dev
->base_addr
!= 0) /* Don't probe at all. */
3596 for (port
= ports
; *port
; port
++) {
3597 err
= smctr_probe1(dev
, *port
);
3604 err
= register_netdev(dev
);
3609 #ifdef CONFIG_MCA_LEGACY
3610 { struct net_local
*tp
= netdev_priv(dev
);
3612 mca_mark_as_unused(tp
->slot_num
);
3615 release_region(dev
->base_addr
, SMCTR_IO_EXTENT
);
3616 free_irq(dev
->irq
, dev
);
3619 return ERR_PTR(err
);
3623 static int __init
smctr_probe1(struct net_device
*dev
, int ioaddr
)
3625 static unsigned version_printed
;
3626 struct net_local
*tp
= netdev_priv(dev
);
3630 if(smctr_debug
&& version_printed
++ == 0)
3633 spin_lock_init(&tp
->lock
);
3634 dev
->base_addr
= ioaddr
;
3636 /* Actually detect an adapter now. */
3637 err
= smctr_chk_isa(dev
);
3640 if ((err
= smctr_chk_mca(dev
)) < 0) {
3646 tp
= netdev_priv(dev
);
3647 dev
->mem_start
= tp
->ram_base
;
3648 dev
->mem_end
= dev
->mem_start
+ 0x10000;
3649 ram
= (__u32
*)phys_to_virt(dev
->mem_start
);
3650 tp
->ram_access
= *(__u32
*)&ram
;
3651 tp
->status
= NOT_INITIALIZED
;
3653 err
= smctr_load_firmware(dev
);
3654 if(err
!= UCODE_PRESENT
&& err
!= SUCCESS
)
3656 printk(KERN_ERR
"%s: Firmware load failed (%d)\n", dev
->name
, err
);
3661 /* Allow user to specify ring speed on module insert. */
3663 tp
->media_type
= MEDIA_UTP_4
;
3665 tp
->media_type
= MEDIA_UTP_16
;
3667 printk(KERN_INFO
"%s: %s %s at Io %#4x, Irq %d, Rom %#4x, Ram %#4x.\n",
3668 dev
->name
, smctr_name
, smctr_model
,
3669 (unsigned int)dev
->base_addr
,
3670 dev
->irq
, tp
->rom_base
, tp
->ram_base
);
3672 dev
->open
= smctr_open
;
3673 dev
->stop
= smctr_close
;
3674 dev
->hard_start_xmit
= smctr_send_packet
;
3675 dev
->tx_timeout
= smctr_timeout
;
3676 dev
->watchdog_timeo
= HZ
;
3677 dev
->get_stats
= smctr_get_stats
;
3678 dev
->set_multicast_list
= &smctr_set_multicast_list
;
3685 static int smctr_process_rx_packet(MAC_HEADER
*rmf
, __u16 size
,
3686 struct net_device
*dev
, __u16 rx_status
)
3688 struct net_local
*tp
= netdev_priv(dev
);
3689 struct sk_buff
*skb
;
3690 __u16 rcode
, correlator
;
3694 rmf
->vl
= SWAP_BYTES(rmf
->vl
);
3695 if(rx_status
& FCB_RX_STATUS_DA_MATCHED
)
3699 /* Received MAC Frames Processed by RS. */
3701 if((rcode
= smctr_rcv_init(dev
, rmf
, &correlator
)) == HARDWARE_FAILED
)
3706 if((err
= smctr_send_rsp(dev
, rmf
, rcode
,
3714 if((rcode
= smctr_rcv_chg_param(dev
, rmf
,
3715 &correlator
)) ==HARDWARE_FAILED
)
3720 if((err
= smctr_send_rsp(dev
, rmf
, rcode
,
3728 if((rcode
= smctr_rcv_rq_addr_state_attch(dev
,
3729 rmf
, &correlator
)) != POSITIVE_ACK
)
3731 if(rcode
== HARDWARE_FAILED
)
3734 return (smctr_send_rsp(dev
, rmf
,
3735 rcode
, correlator
));
3738 if((err
= smctr_send_rpt_addr(dev
, rmf
,
3746 if((rcode
= smctr_rcv_rq_addr_state_attch(dev
,
3747 rmf
, &correlator
)) != POSITIVE_ACK
)
3749 if(rcode
== HARDWARE_FAILED
)
3752 return (smctr_send_rsp(dev
, rmf
,
3757 if((err
= smctr_send_rpt_attch(dev
, rmf
,
3765 if((rcode
= smctr_rcv_rq_addr_state_attch(dev
,
3766 rmf
, &correlator
)) != POSITIVE_ACK
)
3768 if(rcode
== HARDWARE_FAILED
)
3771 return (smctr_send_rsp(dev
, rmf
,
3776 if((err
= smctr_send_rpt_state(dev
, rmf
,
3784 __u16
uninitialized_var(tx_fstatus
);
3786 if((rcode
= smctr_rcv_tx_forward(dev
, rmf
))
3789 if(rcode
== HARDWARE_FAILED
)
3792 return (smctr_send_rsp(dev
, rmf
,
3797 if((err
= smctr_send_tx_forward(dev
, rmf
,
3798 &tx_fstatus
)) == HARDWARE_FAILED
)
3803 if(err
== A_FRAME_WAS_FORWARDED
)
3805 if((err
= smctr_send_rpt_tx_forward(dev
,
3815 /* Received MAC Frames Processed by CRS/REM/RPS. */
3820 case RPT_ACTIVE_ERR
:
3828 /* Rcvd Att. MAC Frame (if RXATMAC set) or UNKNOWN */
3831 if(!(tp
->receive_mask
& ACCEPT_ATT_MAC_FRAMES
))
3833 rcode
= smctr_rcv_unknown(dev
, rmf
,
3835 if((err
= smctr_send_rsp(dev
, rmf
,rcode
,
3847 /* 1. DA doesn't match (Promiscuous Mode).
3848 * 2. Parse for Extended MAC Frame Type.
3866 case RPT_ACTIVE_ERR
:
3875 /* NOTE: UNKNOWN MAC frames will NOT be passed up unless
3876 * ACCEPT_ATT_MAC_FRAMES is set.
3878 if(((tp
->receive_mask
& ACCEPT_ATT_MAC_FRAMES
)
3879 && (xframe
== (__u8
)0))
3880 || ((tp
->receive_mask
& ACCEPT_EXT_MAC_FRAMES
)
3881 && (xframe
== (__u8
)1)))
3883 rmf
->vl
= SWAP_BYTES(rmf
->vl
);
3885 if (!(skb
= dev_alloc_skb(size
)))
3889 /* Slide data into a sleek skb. */
3890 skb_put(skb
, skb
->len
);
3891 skb_copy_to_linear_data(skb
, rmf
, skb
->len
);
3893 /* Update Counters */
3894 tp
->MacStat
.rx_packets
++;
3895 tp
->MacStat
.rx_bytes
+= skb
->len
;
3897 /* Kick the packet on up. */
3898 skb
->protocol
= tr_type_trans(skb
, dev
);
3900 dev
->last_rx
= jiffies
;
3907 /* Adapter RAM test. Incremental word ODD boundary data test. */
3908 static int smctr_ram_memory_test(struct net_device
*dev
)
3910 struct net_local
*tp
= netdev_priv(dev
);
3911 __u16 page
, pages_of_ram
, start_pattern
= 0, word_pattern
= 0,
3912 word_read
= 0, err_word
= 0, err_pattern
= 0;
3913 unsigned int err_offset
;
3917 if(smctr_debug
> 10)
3918 printk(KERN_DEBUG
"%s: smctr_ram_memory_test\n", dev
->name
);
3920 start_pattern
= 0x0001;
3921 pages_of_ram
= tp
->ram_size
/ tp
->ram_usable
;
3922 pword
= tp
->ram_access
;
3924 /* Incremental word ODD boundary test. */
3925 for(page
= 0; (page
< pages_of_ram
) && (~err
);
3926 page
++, start_pattern
+= 0x8000)
3928 smctr_set_page(dev
, (__u8
*)(tp
->ram_access
3929 + (page
* tp
->ram_usable
* 1024) + 1));
3930 word_pattern
= start_pattern
;
3932 for(j
= 1; j
< (__u32
)(tp
->ram_usable
* 1024) - 1; j
+= 2)
3933 *(__u16
*)(pword
+ j
) = word_pattern
++;
3935 word_pattern
= start_pattern
;
3937 for(j
= 1; j
< (__u32
)(tp
->ram_usable
* 1024) - 1
3938 && (~err
); j
+= 2, word_pattern
++)
3940 word_read
= *(__u16
*)(pword
+ j
);
3941 if(word_read
!= word_pattern
)
3945 err_word
= word_read
;
3946 err_pattern
= word_pattern
;
3947 return (RAM_TEST_FAILED
);
3952 /* Zero out memory. */
3953 for(page
= 0; page
< pages_of_ram
&& (~err
); page
++)
3955 smctr_set_page(dev
, (__u8
*)(tp
->ram_access
3956 + (page
* tp
->ram_usable
* 1024)));
3959 for(j
= 0; j
< (__u32
)tp
->ram_usable
* 1024; j
+=2)
3960 *(__u16
*)(pword
+ j
) = word_pattern
;
3962 for(j
=0; j
< (__u32
)tp
->ram_usable
* 1024
3965 word_read
= *(__u16
*)(pword
+ j
);
3966 if(word_read
!= word_pattern
)
3970 err_word
= word_read
;
3971 err_pattern
= word_pattern
;
3972 return (RAM_TEST_FAILED
);
3977 smctr_set_page(dev
, (__u8
*)tp
->ram_access
);
3982 static int smctr_rcv_chg_param(struct net_device
*dev
, MAC_HEADER
*rmf
,
3985 MAC_SUB_VECTOR
*rsv
;
3987 __u16 rcode
= POSITIVE_ACK
;
3988 unsigned int svectors
= F_NO_SUB_VECTORS_FOUND
;
3990 /* This Frame can only come from a CRS */
3991 if((rmf
->dc_sc
& SC_MASK
) != SC_CRS
)
3992 return(E_INAPPROPRIATE_SOURCE_CLASS
);
3994 /* Remove MVID Length from total length. */
3995 vlen
= (signed short)rmf
->vl
- 4;
3997 /* Point to First SVID */
3998 rsv
= (MAC_SUB_VECTOR
*)((__u32
)rmf
+ sizeof(MAC_HEADER
));
4000 /* Search for Appropriate SVID's. */
4001 while((vlen
> 0) && (rcode
== POSITIVE_ACK
))
4006 svectors
|= F_CORRELATOR
;
4007 rcode
= smctr_set_corr(dev
, rsv
, correlator
);
4010 case LOCAL_RING_NUMBER
:
4011 svectors
|= F_LOCAL_RING_NUMBER
;
4012 rcode
= smctr_set_local_ring_num(dev
, rsv
);
4015 case ASSIGN_PHYSICAL_DROP
:
4016 svectors
|= F_ASSIGN_PHYSICAL_DROP
;
4017 rcode
= smctr_set_phy_drop(dev
, rsv
);
4020 case ERROR_TIMER_VALUE
:
4021 svectors
|= F_ERROR_TIMER_VALUE
;
4022 rcode
= smctr_set_error_timer_value(dev
, rsv
);
4025 case AUTHORIZED_FUNCTION_CLASS
:
4026 svectors
|= F_AUTHORIZED_FUNCTION_CLASS
;
4027 rcode
= smctr_set_auth_funct_class(dev
, rsv
);
4030 case AUTHORIZED_ACCESS_PRIORITY
:
4031 svectors
|= F_AUTHORIZED_ACCESS_PRIORITY
;
4032 rcode
= smctr_set_auth_access_pri(dev
, rsv
);
4036 rcode
= E_SUB_VECTOR_UNKNOWN
;
4040 /* Let Sender Know if SUM of SV length's is
4041 * larger then length in MVID length field
4043 if((vlen
-= rsv
->svl
) < 0)
4044 rcode
= E_VECTOR_LENGTH_ERROR
;
4046 rsv
= (MAC_SUB_VECTOR
*)((__u32
)rsv
+ rsv
->svl
);
4049 if(rcode
== POSITIVE_ACK
)
4051 /* Let Sender Know if MVID length field
4052 * is larger then SUM of SV length's
4055 rcode
= E_VECTOR_LENGTH_ERROR
;
4058 /* Let Sender Know if Expected SVID Missing */
4059 if((svectors
& R_CHG_PARM
) ^ R_CHG_PARM
)
4060 rcode
= E_MISSING_SUB_VECTOR
;
4067 static int smctr_rcv_init(struct net_device
*dev
, MAC_HEADER
*rmf
,
4070 MAC_SUB_VECTOR
*rsv
;
4072 __u16 rcode
= POSITIVE_ACK
;
4073 unsigned int svectors
= F_NO_SUB_VECTORS_FOUND
;
4075 /* This Frame can only come from a RPS */
4076 if((rmf
->dc_sc
& SC_MASK
) != SC_RPS
)
4077 return (E_INAPPROPRIATE_SOURCE_CLASS
);
4079 /* Remove MVID Length from total length. */
4080 vlen
= (signed short)rmf
->vl
- 4;
4082 /* Point to First SVID */
4083 rsv
= (MAC_SUB_VECTOR
*)((__u32
)rmf
+ sizeof(MAC_HEADER
));
4085 /* Search for Appropriate SVID's */
4086 while((vlen
> 0) && (rcode
== POSITIVE_ACK
))
4091 svectors
|= F_CORRELATOR
;
4092 rcode
= smctr_set_corr(dev
, rsv
, correlator
);
4095 case LOCAL_RING_NUMBER
:
4096 svectors
|= F_LOCAL_RING_NUMBER
;
4097 rcode
= smctr_set_local_ring_num(dev
, rsv
);
4100 case ASSIGN_PHYSICAL_DROP
:
4101 svectors
|= F_ASSIGN_PHYSICAL_DROP
;
4102 rcode
= smctr_set_phy_drop(dev
, rsv
);
4105 case ERROR_TIMER_VALUE
:
4106 svectors
|= F_ERROR_TIMER_VALUE
;
4107 rcode
= smctr_set_error_timer_value(dev
, rsv
);
4111 rcode
= E_SUB_VECTOR_UNKNOWN
;
4115 /* Let Sender Know if SUM of SV length's is
4116 * larger then length in MVID length field
4118 if((vlen
-= rsv
->svl
) < 0)
4119 rcode
= E_VECTOR_LENGTH_ERROR
;
4121 rsv
= (MAC_SUB_VECTOR
*)((__u32
)rsv
+ rsv
->svl
);
4124 if(rcode
== POSITIVE_ACK
)
4126 /* Let Sender Know if MVID length field
4127 * is larger then SUM of SV length's
4130 rcode
= E_VECTOR_LENGTH_ERROR
;
4133 /* Let Sender Know if Expected SV Missing */
4134 if((svectors
& R_INIT
) ^ R_INIT
)
4135 rcode
= E_MISSING_SUB_VECTOR
;
4142 static int smctr_rcv_tx_forward(struct net_device
*dev
, MAC_HEADER
*rmf
)
4144 MAC_SUB_VECTOR
*rsv
;
4146 __u16 rcode
= POSITIVE_ACK
;
4147 unsigned int svectors
= F_NO_SUB_VECTORS_FOUND
;
4149 /* This Frame can only come from a CRS */
4150 if((rmf
->dc_sc
& SC_MASK
) != SC_CRS
)
4151 return (E_INAPPROPRIATE_SOURCE_CLASS
);
4153 /* Remove MVID Length from total length */
4154 vlen
= (signed short)rmf
->vl
- 4;
4156 /* Point to First SVID */
4157 rsv
= (MAC_SUB_VECTOR
*)((__u32
)rmf
+ sizeof(MAC_HEADER
));
4159 /* Search for Appropriate SVID's */
4160 while((vlen
> 0) && (rcode
== POSITIVE_ACK
))
4165 svectors
|= F_FRAME_FORWARD
;
4166 rcode
= smctr_set_frame_forward(dev
, rsv
,
4171 rcode
= E_SUB_VECTOR_UNKNOWN
;
4175 /* Let Sender Know if SUM of SV length's is
4176 * larger then length in MVID length field
4178 if((vlen
-= rsv
->svl
) < 0)
4179 rcode
= E_VECTOR_LENGTH_ERROR
;
4181 rsv
= (MAC_SUB_VECTOR
*)((__u32
)rsv
+ rsv
->svl
);
4184 if(rcode
== POSITIVE_ACK
)
4186 /* Let Sender Know if MVID length field
4187 * is larger then SUM of SV length's
4190 rcode
= E_VECTOR_LENGTH_ERROR
;
4193 /* Let Sender Know if Expected SV Missing */
4194 if((svectors
& R_TX_FORWARD
) ^ R_TX_FORWARD
)
4195 rcode
= E_MISSING_SUB_VECTOR
;
4202 static int smctr_rcv_rq_addr_state_attch(struct net_device
*dev
,
4203 MAC_HEADER
*rmf
, __u16
*correlator
)
4205 MAC_SUB_VECTOR
*rsv
;
4207 __u16 rcode
= POSITIVE_ACK
;
4208 unsigned int svectors
= F_NO_SUB_VECTORS_FOUND
;
4210 /* Remove MVID Length from total length */
4211 vlen
= (signed short)rmf
->vl
- 4;
4213 /* Point to First SVID */
4214 rsv
= (MAC_SUB_VECTOR
*)((__u32
)rmf
+ sizeof(MAC_HEADER
));
4216 /* Search for Appropriate SVID's */
4217 while((vlen
> 0) && (rcode
== POSITIVE_ACK
))
4222 svectors
|= F_CORRELATOR
;
4223 rcode
= smctr_set_corr(dev
, rsv
, correlator
);
4227 rcode
= E_SUB_VECTOR_UNKNOWN
;
4231 /* Let Sender Know if SUM of SV length's is
4232 * larger then length in MVID length field
4234 if((vlen
-= rsv
->svl
) < 0)
4235 rcode
= E_VECTOR_LENGTH_ERROR
;
4237 rsv
= (MAC_SUB_VECTOR
*)((__u32
)rsv
+ rsv
->svl
);
4240 if(rcode
== POSITIVE_ACK
)
4242 /* Let Sender Know if MVID length field
4243 * is larger then SUM of SV length's
4246 rcode
= E_VECTOR_LENGTH_ERROR
;
4249 /* Let Sender Know if Expected SVID Missing */
4250 if((svectors
& R_RQ_ATTCH_STATE_ADDR
)
4251 ^ R_RQ_ATTCH_STATE_ADDR
)
4252 rcode
= E_MISSING_SUB_VECTOR
;
4259 static int smctr_rcv_unknown(struct net_device
*dev
, MAC_HEADER
*rmf
,
4262 MAC_SUB_VECTOR
*rsv
;
4267 /* Remove MVID Length from total length */
4268 vlen
= (signed short)rmf
->vl
- 4;
4270 /* Point to First SVID */
4271 rsv
= (MAC_SUB_VECTOR
*)((__u32
)rmf
+ sizeof(MAC_HEADER
));
4273 /* Search for CORRELATOR for RSP to UNKNOWN */
4274 while((vlen
> 0) && (*correlator
== 0))
4279 smctr_set_corr(dev
, rsv
, correlator
);
4287 rsv
= (MAC_SUB_VECTOR
*)((__u32
)rsv
+ rsv
->svl
);
4290 return (E_UNRECOGNIZED_VECTOR_ID
);
4294 * Reset the 825 NIC and exit w:
4295 * 1. The NIC reset cleared (non-reset state), halted and un-initialized.
4301 static int smctr_reset_adapter(struct net_device
*dev
)
4303 struct net_local
*tp
= netdev_priv(dev
);
4304 int ioaddr
= dev
->base_addr
;
4306 /* Reseting the NIC will put it in a halted and un-initialized state. */ smctr_set_trc_reset(ioaddr
);
4307 mdelay(200); /* ~2 ms */
4309 smctr_clear_trc_reset(ioaddr
);
4310 mdelay(200); /* ~2 ms */
4312 /* Remove any latched interrupts that occurred prior to reseting the
4313 * adapter or possibily caused by line glitches due to the reset.
4315 outb(tp
->trc_mask
| CSR_CLRTINT
| CSR_CLRCBUSY
, ioaddr
+ CSR
);
4320 static int smctr_restart_tx_chain(struct net_device
*dev
, short queue
)
4322 struct net_local
*tp
= netdev_priv(dev
);
4325 if(smctr_debug
> 10)
4326 printk(KERN_DEBUG
"%s: smctr_restart_tx_chain\n", dev
->name
);
4328 if(tp
->num_tx_fcbs_used
[queue
] != 0
4329 && tp
->tx_queue_status
[queue
] == NOT_TRANSMITING
)
4331 tp
->tx_queue_status
[queue
] = TRANSMITING
;
4332 err
= smctr_issue_resume_tx_fcb_cmd(dev
, queue
);
4338 static int smctr_ring_status_chg(struct net_device
*dev
)
4340 struct net_local
*tp
= netdev_priv(dev
);
4342 if(smctr_debug
> 10)
4343 printk(KERN_DEBUG
"%s: smctr_ring_status_chg\n", dev
->name
);
4345 /* Check for ring_status_flag: whenever MONITOR_STATE_BIT
4346 * Bit is set, check value of monitor_state, only then we
4347 * enable and start transmit/receive timeout (if and only
4348 * if it is MS_ACTIVE_MONITOR_STATE or MS_STANDBY_MONITOR_STATE)
4350 if(tp
->ring_status_flags
== MONITOR_STATE_CHANGED
)
4352 if((tp
->monitor_state
== MS_ACTIVE_MONITOR_STATE
)
4353 || (tp
->monitor_state
== MS_STANDBY_MONITOR_STATE
))
4355 tp
->monitor_state_ready
= 1;
4359 /* if adapter is NOT in either active monitor
4360 * or standby monitor state => Disable
4361 * transmit/receive timeout.
4363 tp
->monitor_state_ready
= 0;
4365 /* Ring speed problem, switching to auto mode. */
4366 if(tp
->monitor_state
== MS_MONITOR_FSM_INACTIVE
4369 printk(KERN_INFO
"%s: Incorrect ring speed switching.\n",
4371 smctr_set_ring_speed(dev
);
4376 if(!(tp
->ring_status_flags
& RING_STATUS_CHANGED
))
4379 switch(tp
->ring_status
)
4382 printk(KERN_INFO
"%s: Ring Recovery\n", dev
->name
);
4383 tp
->current_ring_status
|= RING_RECOVERY
;
4386 case SINGLE_STATION
:
4387 printk(KERN_INFO
"%s: Single Statinon\n", dev
->name
);
4388 tp
->current_ring_status
|= SINGLE_STATION
;
4391 case COUNTER_OVERFLOW
:
4392 printk(KERN_INFO
"%s: Counter Overflow\n", dev
->name
);
4393 tp
->current_ring_status
|= COUNTER_OVERFLOW
;
4396 case REMOVE_RECEIVED
:
4397 printk(KERN_INFO
"%s: Remove Received\n", dev
->name
);
4398 tp
->current_ring_status
|= REMOVE_RECEIVED
;
4401 case AUTO_REMOVAL_ERROR
:
4402 printk(KERN_INFO
"%s: Auto Remove Error\n", dev
->name
);
4403 tp
->current_ring_status
|= AUTO_REMOVAL_ERROR
;
4406 case LOBE_WIRE_FAULT
:
4407 printk(KERN_INFO
"%s: Lobe Wire Fault\n", dev
->name
);
4408 tp
->current_ring_status
|= LOBE_WIRE_FAULT
;
4411 case TRANSMIT_BEACON
:
4412 printk(KERN_INFO
"%s: Transmit Beacon\n", dev
->name
);
4413 tp
->current_ring_status
|= TRANSMIT_BEACON
;
4417 printk(KERN_INFO
"%s: Soft Error\n", dev
->name
);
4418 tp
->current_ring_status
|= SOFT_ERROR
;
4422 printk(KERN_INFO
"%s: Hard Error\n", dev
->name
);
4423 tp
->current_ring_status
|= HARD_ERROR
;
4427 printk(KERN_INFO
"%s: Signal Loss\n", dev
->name
);
4428 tp
->current_ring_status
|= SIGNAL_LOSS
;
4432 printk(KERN_INFO
"%s: Unknown ring status change\n",
4440 static int smctr_rx_frame(struct net_device
*dev
)
4442 struct net_local
*tp
= netdev_priv(dev
);
4443 __u16 queue
, status
, rx_size
, err
= 0;
4446 if(smctr_debug
> 10)
4447 printk(KERN_DEBUG
"%s: smctr_rx_frame\n", dev
->name
);
4449 queue
= tp
->receive_queue_number
;
4451 while((status
= tp
->rx_fcb_curr
[queue
]->frame_status
) != SUCCESS
)
4453 err
= HARDWARE_FAILED
;
4455 if(((status
& 0x007f) == 0)
4456 || ((tp
->receive_mask
& ACCEPT_ERR_PACKETS
) != 0))
4458 /* frame length less the CRC (4 bytes) + FS (1 byte) */
4459 rx_size
= tp
->rx_fcb_curr
[queue
]->frame_length
- 5;
4461 pbuff
= smctr_get_rx_pointer(dev
, queue
);
4463 smctr_set_page(dev
, pbuff
);
4464 smctr_disable_16bit(dev
);
4466 /* pbuff points to addr within one page */
4467 pbuff
= (__u8
*)PAGE_POINTER(pbuff
);
4469 if(queue
== NON_MAC_QUEUE
)
4471 struct sk_buff
*skb
;
4473 skb
= dev_alloc_skb(rx_size
);
4475 skb_put(skb
, rx_size
);
4477 skb_copy_to_linear_data(skb
, pbuff
, rx_size
);
4479 /* Update Counters */
4480 tp
->MacStat
.rx_packets
++;
4481 tp
->MacStat
.rx_bytes
+= skb
->len
;
4483 /* Kick the packet on up. */
4484 skb
->protocol
= tr_type_trans(skb
, dev
);
4486 dev
->last_rx
= jiffies
;
4491 smctr_process_rx_packet((MAC_HEADER
*)pbuff
,
4492 rx_size
, dev
, status
);
4495 smctr_enable_16bit(dev
);
4496 smctr_set_page(dev
, (__u8
*)tp
->ram_access
);
4497 smctr_update_rx_chain(dev
, queue
);
4506 static int smctr_send_dat(struct net_device
*dev
)
4508 struct net_local
*tp
= netdev_priv(dev
);
4509 unsigned int i
, err
;
4513 if(smctr_debug
> 10)
4514 printk(KERN_DEBUG
"%s: smctr_send_dat\n", dev
->name
);
4516 if((fcb
= smctr_get_tx_fcb(dev
, MAC_QUEUE
,
4517 sizeof(MAC_HEADER
))) == (FCBlock
*)(-1L))
4519 return (OUT_OF_RESOURCES
);
4522 /* Initialize DAT Data Fields. */
4523 tmf
= (MAC_HEADER
*)fcb
->bdb_ptr
->data_block_ptr
;
4524 tmf
->ac
= MSB(AC_FC_DAT
);
4525 tmf
->fc
= LSB(AC_FC_DAT
);
4527 for(i
= 0; i
< 6; i
++)
4529 tmf
->sa
[i
] = dev
->dev_addr
[i
];
4530 tmf
->da
[i
] = dev
->dev_addr
[i
];
4535 tmf
->dc_sc
= DC_RS
| SC_RS
;
4537 tmf
->vl
= SWAP_BYTES(tmf
->vl
);
4539 /* Start Transmit. */
4540 if((err
= smctr_trc_send_packet(dev
, fcb
, MAC_QUEUE
)))
4543 /* Wait for Transmit to Complete */
4544 for(i
= 0; i
< 10000; i
++)
4546 if(fcb
->frame_status
& FCB_COMMAND_DONE
)
4551 /* Check if GOOD frame Tx'ed. */
4552 if(!(fcb
->frame_status
& FCB_COMMAND_DONE
)
4553 || fcb
->frame_status
& (FCB_TX_STATUS_E
| FCB_TX_AC_BITS
))
4555 return (INITIALIZE_FAILED
);
4558 /* De-allocated Tx FCB and Frame Buffer
4559 * The FCB must be de-allocated manually if executing with
4560 * interrupts disabled, other wise the ISR (LM_Service_Events)
4561 * will de-allocate it when the interrupt occurs.
4563 tp
->tx_queue_status
[MAC_QUEUE
] = NOT_TRANSMITING
;
4564 smctr_update_tx_chain(dev
, fcb
, MAC_QUEUE
);
4569 static void smctr_timeout(struct net_device
*dev
)
4572 * If we get here, some higher level has decided we are broken.
4573 * There should really be a "kick me" function call instead.
4575 * Resetting the token ring adapter takes a long time so just
4576 * fake transmission time and go on trying. Our own timeout
4577 * routine is in sktr_timer_chk()
4579 dev
->trans_start
= jiffies
;
4580 netif_wake_queue(dev
);
4584 * Gets skb from system, queues it and checks if it can be sent
4586 static int smctr_send_packet(struct sk_buff
*skb
, struct net_device
*dev
)
4588 struct net_local
*tp
= netdev_priv(dev
);
4590 if(smctr_debug
> 10)
4591 printk(KERN_DEBUG
"%s: smctr_send_packet\n", dev
->name
);
4594 * Block a transmit overlap
4597 netif_stop_queue(dev
);
4599 if(tp
->QueueSkb
== 0)
4600 return (1); /* Return with tbusy set: queue full */
4603 skb_queue_tail(&tp
->SendSkbQueue
, skb
);
4604 smctr_hardware_send_packet(dev
, tp
);
4605 if(tp
->QueueSkb
> 0)
4606 netif_wake_queue(dev
);
4611 static int smctr_send_lobe_media_test(struct net_device
*dev
)
4613 struct net_local
*tp
= netdev_priv(dev
);
4614 MAC_SUB_VECTOR
*tsv
;
4620 if(smctr_debug
> 15)
4621 printk(KERN_DEBUG
"%s: smctr_send_lobe_media_test\n", dev
->name
);
4623 if((fcb
= smctr_get_tx_fcb(dev
, MAC_QUEUE
, sizeof(struct trh_hdr
)
4624 + S_WRAP_DATA
+ S_WRAP_DATA
)) == (FCBlock
*)(-1L))
4626 return (OUT_OF_RESOURCES
);
4629 /* Initialize DAT Data Fields. */
4630 tmf
= (MAC_HEADER
*)fcb
->bdb_ptr
->data_block_ptr
;
4631 tmf
->ac
= MSB(AC_FC_LOBE_MEDIA_TEST
);
4632 tmf
->fc
= LSB(AC_FC_LOBE_MEDIA_TEST
);
4634 for(i
= 0; i
< 6; i
++)
4637 tmf
->sa
[i
] = dev
->dev_addr
[i
];
4640 tmf
->vc
= LOBE_MEDIA_TEST
;
4641 tmf
->dc_sc
= DC_RS
| SC_RS
;
4644 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tmf
+ sizeof(MAC_HEADER
));
4645 smctr_make_wrap_data(dev
, tsv
);
4646 tmf
->vl
+= tsv
->svl
;
4648 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tsv
+ tsv
->svl
);
4649 smctr_make_wrap_data(dev
, tsv
);
4650 tmf
->vl
+= tsv
->svl
;
4652 /* Start Transmit. */
4653 tmf
->vl
= SWAP_BYTES(tmf
->vl
);
4654 if((err
= smctr_trc_send_packet(dev
, fcb
, MAC_QUEUE
)))
4657 /* Wait for Transmit to Complete. (10 ms). */
4658 for(i
=0; i
< 10000; i
++)
4660 if(fcb
->frame_status
& FCB_COMMAND_DONE
)
4665 /* Check if GOOD frame Tx'ed */
4666 if(!(fcb
->frame_status
& FCB_COMMAND_DONE
)
4667 || fcb
->frame_status
& (FCB_TX_STATUS_E
| FCB_TX_AC_BITS
))
4669 return (LOBE_MEDIA_TEST_FAILED
);
4672 /* De-allocated Tx FCB and Frame Buffer
4673 * The FCB must be de-allocated manually if executing with
4674 * interrupts disabled, other wise the ISR (LM_Service_Events)
4675 * will de-allocate it when the interrupt occurs.
4677 tp
->tx_queue_status
[MAC_QUEUE
] = NOT_TRANSMITING
;
4678 smctr_update_tx_chain(dev
, fcb
, MAC_QUEUE
);
4683 static int smctr_send_rpt_addr(struct net_device
*dev
, MAC_HEADER
*rmf
,
4687 MAC_SUB_VECTOR
*tsv
;
4690 if((fcb
= smctr_get_tx_fcb(dev
, MAC_QUEUE
, sizeof(MAC_HEADER
)
4691 + S_CORRELATOR
+ S_PHYSICAL_DROP
+ S_UPSTREAM_NEIGHBOR_ADDRESS
4692 + S_ADDRESS_MODIFER
+ S_GROUP_ADDRESS
+ S_FUNCTIONAL_ADDRESS
))
4693 == (FCBlock
*)(-1L))
4698 tmf
= (MAC_HEADER
*)fcb
->bdb_ptr
->data_block_ptr
;
4700 tmf
->dc_sc
= (rmf
->dc_sc
& SC_MASK
) << 4;
4703 smctr_make_8025_hdr(dev
, rmf
, tmf
, AC_FC_RPT_ADDR
);
4705 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tmf
+ sizeof(MAC_HEADER
));
4706 smctr_make_corr(dev
, tsv
, correlator
);
4708 tmf
->vl
+= tsv
->svl
;
4709 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tsv
+ tsv
->svl
);
4710 smctr_make_phy_drop_num(dev
, tsv
);
4712 tmf
->vl
+= tsv
->svl
;
4713 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tsv
+ tsv
->svl
);
4714 smctr_make_upstream_neighbor_addr(dev
, tsv
);
4716 tmf
->vl
+= tsv
->svl
;
4717 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tsv
+ tsv
->svl
);
4718 smctr_make_addr_mod(dev
, tsv
);
4720 tmf
->vl
+= tsv
->svl
;
4721 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tsv
+ tsv
->svl
);
4722 smctr_make_group_addr(dev
, tsv
);
4724 tmf
->vl
+= tsv
->svl
;
4725 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tsv
+ tsv
->svl
);
4726 smctr_make_funct_addr(dev
, tsv
);
4728 tmf
->vl
+= tsv
->svl
;
4730 /* Subtract out MVID and MVL which is
4731 * include in both vl and MAC_HEADER
4733 /* fcb->frame_length = tmf->vl + sizeof(MAC_HEADER) - 4;
4734 fcb->bdb_ptr->buffer_length = tmf->vl + sizeof(MAC_HEADER) - 4;
4736 tmf
->vl
= SWAP_BYTES(tmf
->vl
);
4738 return (smctr_trc_send_packet(dev
, fcb
, MAC_QUEUE
));
4741 static int smctr_send_rpt_attch(struct net_device
*dev
, MAC_HEADER
*rmf
,
4745 MAC_SUB_VECTOR
*tsv
;
4748 if((fcb
= smctr_get_tx_fcb(dev
, MAC_QUEUE
, sizeof(MAC_HEADER
)
4749 + S_CORRELATOR
+ S_PRODUCT_INSTANCE_ID
+ S_FUNCTIONAL_ADDRESS
4750 + S_AUTHORIZED_FUNCTION_CLASS
+ S_AUTHORIZED_ACCESS_PRIORITY
))
4751 == (FCBlock
*)(-1L))
4756 tmf
= (MAC_HEADER
*)fcb
->bdb_ptr
->data_block_ptr
;
4757 tmf
->vc
= RPT_ATTCH
;
4758 tmf
->dc_sc
= (rmf
->dc_sc
& SC_MASK
) << 4;
4761 smctr_make_8025_hdr(dev
, rmf
, tmf
, AC_FC_RPT_ATTCH
);
4763 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tmf
+ sizeof(MAC_HEADER
));
4764 smctr_make_corr(dev
, tsv
, correlator
);
4766 tmf
->vl
+= tsv
->svl
;
4767 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tsv
+ tsv
->svl
);
4768 smctr_make_product_id(dev
, tsv
);
4770 tmf
->vl
+= tsv
->svl
;
4771 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tsv
+ tsv
->svl
);
4772 smctr_make_funct_addr(dev
, tsv
);
4774 tmf
->vl
+= tsv
->svl
;
4775 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tsv
+ tsv
->svl
);
4776 smctr_make_auth_funct_class(dev
, tsv
);
4778 tmf
->vl
+= tsv
->svl
;
4779 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tsv
+ tsv
->svl
);
4780 smctr_make_access_pri(dev
, tsv
);
4782 tmf
->vl
+= tsv
->svl
;
4784 /* Subtract out MVID and MVL which is
4785 * include in both vl and MAC_HEADER
4787 /* fcb->frame_length = tmf->vl + sizeof(MAC_HEADER) - 4;
4788 fcb->bdb_ptr->buffer_length = tmf->vl + sizeof(MAC_HEADER) - 4;
4790 tmf
->vl
= SWAP_BYTES(tmf
->vl
);
4792 return (smctr_trc_send_packet(dev
, fcb
, MAC_QUEUE
));
4795 static int smctr_send_rpt_state(struct net_device
*dev
, MAC_HEADER
*rmf
,
4799 MAC_SUB_VECTOR
*tsv
;
4802 if((fcb
= smctr_get_tx_fcb(dev
, MAC_QUEUE
, sizeof(MAC_HEADER
)
4803 + S_CORRELATOR
+ S_RING_STATION_VERSION_NUMBER
4804 + S_RING_STATION_STATUS
+ S_STATION_IDENTIFER
))
4805 == (FCBlock
*)(-1L))
4810 tmf
= (MAC_HEADER
*)fcb
->bdb_ptr
->data_block_ptr
;
4811 tmf
->vc
= RPT_STATE
;
4812 tmf
->dc_sc
= (rmf
->dc_sc
& SC_MASK
) << 4;
4815 smctr_make_8025_hdr(dev
, rmf
, tmf
, AC_FC_RPT_STATE
);
4817 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tmf
+ sizeof(MAC_HEADER
));
4818 smctr_make_corr(dev
, tsv
, correlator
);
4820 tmf
->vl
+= tsv
->svl
;
4821 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tsv
+ tsv
->svl
);
4822 smctr_make_ring_station_version(dev
, tsv
);
4824 tmf
->vl
+= tsv
->svl
;
4825 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tsv
+ tsv
->svl
);
4826 smctr_make_ring_station_status(dev
, tsv
);
4828 tmf
->vl
+= tsv
->svl
;
4829 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tsv
+ tsv
->svl
);
4830 smctr_make_station_id(dev
, tsv
);
4832 tmf
->vl
+= tsv
->svl
;
4834 /* Subtract out MVID and MVL which is
4835 * include in both vl and MAC_HEADER
4837 /* fcb->frame_length = tmf->vl + sizeof(MAC_HEADER) - 4;
4838 fcb->bdb_ptr->buffer_length = tmf->vl + sizeof(MAC_HEADER) - 4;
4840 tmf
->vl
= SWAP_BYTES(tmf
->vl
);
4842 return (smctr_trc_send_packet(dev
, fcb
, MAC_QUEUE
));
4845 static int smctr_send_rpt_tx_forward(struct net_device
*dev
,
4846 MAC_HEADER
*rmf
, __u16 tx_fstatus
)
4849 MAC_SUB_VECTOR
*tsv
;
4852 if((fcb
= smctr_get_tx_fcb(dev
, MAC_QUEUE
, sizeof(MAC_HEADER
)
4853 + S_TRANSMIT_STATUS_CODE
)) == (FCBlock
*)(-1L))
4858 tmf
= (MAC_HEADER
*)fcb
->bdb_ptr
->data_block_ptr
;
4859 tmf
->vc
= RPT_TX_FORWARD
;
4860 tmf
->dc_sc
= (rmf
->dc_sc
& SC_MASK
) << 4;
4863 smctr_make_8025_hdr(dev
, rmf
, tmf
, AC_FC_RPT_TX_FORWARD
);
4865 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tmf
+ sizeof(MAC_HEADER
));
4866 smctr_make_tx_status_code(dev
, tsv
, tx_fstatus
);
4868 tmf
->vl
+= tsv
->svl
;
4870 /* Subtract out MVID and MVL which is
4871 * include in both vl and MAC_HEADER
4873 /* fcb->frame_length = tmf->vl + sizeof(MAC_HEADER) - 4;
4874 fcb->bdb_ptr->buffer_length = tmf->vl + sizeof(MAC_HEADER) - 4;
4876 tmf
->vl
= SWAP_BYTES(tmf
->vl
);
4878 return(smctr_trc_send_packet(dev
, fcb
, MAC_QUEUE
));
4881 static int smctr_send_rsp(struct net_device
*dev
, MAC_HEADER
*rmf
,
4882 __u16 rcode
, __u16 correlator
)
4885 MAC_SUB_VECTOR
*tsv
;
4888 if((fcb
= smctr_get_tx_fcb(dev
, MAC_QUEUE
, sizeof(MAC_HEADER
)
4889 + S_CORRELATOR
+ S_RESPONSE_CODE
)) == (FCBlock
*)(-1L))
4894 tmf
= (MAC_HEADER
*)fcb
->bdb_ptr
->data_block_ptr
;
4896 tmf
->dc_sc
= (rmf
->dc_sc
& SC_MASK
) << 4;
4899 smctr_make_8025_hdr(dev
, rmf
, tmf
, AC_FC_RSP
);
4901 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tmf
+ sizeof(MAC_HEADER
));
4902 smctr_make_corr(dev
, tsv
, correlator
);
4907 static int smctr_send_rq_init(struct net_device
*dev
)
4909 struct net_local
*tp
= netdev_priv(dev
);
4911 MAC_SUB_VECTOR
*tsv
;
4913 unsigned int i
, count
= 0;
4918 if(((fcb
= smctr_get_tx_fcb(dev
, MAC_QUEUE
, sizeof(MAC_HEADER
)
4919 + S_PRODUCT_INSTANCE_ID
+ S_UPSTREAM_NEIGHBOR_ADDRESS
4920 + S_RING_STATION_VERSION_NUMBER
+ S_ADDRESS_MODIFER
))
4921 == (FCBlock
*)(-1L)))
4926 tmf
= (MAC_HEADER
*)fcb
->bdb_ptr
->data_block_ptr
;
4928 tmf
->dc_sc
= DC_RPS
| SC_RS
;
4931 smctr_make_8025_hdr(dev
, NULL
, tmf
, AC_FC_RQ_INIT
);
4933 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tmf
+ sizeof(MAC_HEADER
));
4934 smctr_make_product_id(dev
, tsv
);
4936 tmf
->vl
+= tsv
->svl
;
4937 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tsv
+ tsv
->svl
);
4938 smctr_make_upstream_neighbor_addr(dev
, tsv
);
4940 tmf
->vl
+= tsv
->svl
;
4941 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tsv
+ tsv
->svl
);
4942 smctr_make_ring_station_version(dev
, tsv
);
4944 tmf
->vl
+= tsv
->svl
;
4945 tsv
= (MAC_SUB_VECTOR
*)((__u32
)tsv
+ tsv
->svl
);
4946 smctr_make_addr_mod(dev
, tsv
);
4948 tmf
->vl
+= tsv
->svl
;
4950 /* Subtract out MVID and MVL which is
4951 * include in both vl and MAC_HEADER
4953 /* fcb->frame_length = tmf->vl + sizeof(MAC_HEADER) - 4;
4954 fcb->bdb_ptr->buffer_length = tmf->vl + sizeof(MAC_HEADER) - 4;
4956 tmf
->vl
= SWAP_BYTES(tmf
->vl
);
4958 if((err
= smctr_trc_send_packet(dev
, fcb
, MAC_QUEUE
)))
4961 /* Wait for Transmit to Complete */
4962 for(i
= 0; i
< 10000; i
++)
4964 if(fcb
->frame_status
& FCB_COMMAND_DONE
)
4969 /* Check if GOOD frame Tx'ed */
4970 fstatus
= fcb
->frame_status
;
4972 if(!(fstatus
& FCB_COMMAND_DONE
))
4973 return (HARDWARE_FAILED
);
4975 if(!(fstatus
& FCB_TX_STATUS_E
))
4978 /* De-allocated Tx FCB and Frame Buffer
4979 * The FCB must be de-allocated manually if executing with
4980 * interrupts disabled, other wise the ISR (LM_Service_Events)
4981 * will de-allocate it when the interrupt occurs.
4983 tp
->tx_queue_status
[MAC_QUEUE
] = NOT_TRANSMITING
;
4984 smctr_update_tx_chain(dev
, fcb
, MAC_QUEUE
);
4985 } while(count
< 4 && ((fstatus
& FCB_TX_AC_BITS
) ^ FCB_TX_AC_BITS
));
4987 return (smctr_join_complete_state(dev
));
4990 static int smctr_send_tx_forward(struct net_device
*dev
, MAC_HEADER
*rmf
,
4993 struct net_local
*tp
= netdev_priv(dev
);
4998 /* Check if this is the END POINT of the Transmit Forward Chain. */
5002 /* Allocate Transmit FCB only by requesting 0 bytes
5005 if((fcb
= smctr_get_tx_fcb(dev
, MAC_QUEUE
, 0)) == (FCBlock
*)(-1L))
5008 /* Set pointer to Transmit Frame Buffer to the data
5009 * portion of the received TX Forward frame, making
5010 * sure to skip over the Vector Code (vc) and Vector
5013 fcb
->bdb_ptr
->trc_data_block_ptr
= TRC_POINTER((__u32
)rmf
5014 + sizeof(MAC_HEADER
) + 2);
5015 fcb
->bdb_ptr
->data_block_ptr
= (__u16
*)((__u32
)rmf
5016 + sizeof(MAC_HEADER
) + 2);
5018 fcb
->frame_length
= rmf
->vl
- 4 - 2;
5019 fcb
->bdb_ptr
->buffer_length
= rmf
->vl
- 4 - 2;
5021 if((err
= smctr_trc_send_packet(dev
, fcb
, MAC_QUEUE
)))
5024 /* Wait for Transmit to Complete */
5025 for(i
= 0; i
< 10000; i
++)
5027 if(fcb
->frame_status
& FCB_COMMAND_DONE
)
5032 /* Check if GOOD frame Tx'ed */
5033 if(!(fcb
->frame_status
& FCB_COMMAND_DONE
))
5035 if((err
= smctr_issue_resume_tx_fcb_cmd(dev
, MAC_QUEUE
)))
5038 for(i
= 0; i
< 10000; i
++)
5040 if(fcb
->frame_status
& FCB_COMMAND_DONE
)
5045 if(!(fcb
->frame_status
& FCB_COMMAND_DONE
))
5046 return (HARDWARE_FAILED
);
5049 *tx_fstatus
= fcb
->frame_status
;
5051 return (A_FRAME_WAS_FORWARDED
);
5054 static int smctr_set_auth_access_pri(struct net_device
*dev
,
5055 MAC_SUB_VECTOR
*rsv
)
5057 struct net_local
*tp
= netdev_priv(dev
);
5059 if(rsv
->svl
!= S_AUTHORIZED_ACCESS_PRIORITY
)
5060 return (E_SUB_VECTOR_LENGTH_ERROR
);
5062 tp
->authorized_access_priority
= (rsv
->svv
[0] << 8 | rsv
->svv
[1]);
5064 return (POSITIVE_ACK
);
5067 static int smctr_set_auth_funct_class(struct net_device
*dev
,
5068 MAC_SUB_VECTOR
*rsv
)
5070 struct net_local
*tp
= netdev_priv(dev
);
5072 if(rsv
->svl
!= S_AUTHORIZED_FUNCTION_CLASS
)
5073 return (E_SUB_VECTOR_LENGTH_ERROR
);
5075 tp
->authorized_function_classes
= (rsv
->svv
[0] << 8 | rsv
->svv
[1]);
5077 return (POSITIVE_ACK
);
5080 static int smctr_set_corr(struct net_device
*dev
, MAC_SUB_VECTOR
*rsv
,
5083 if(rsv
->svl
!= S_CORRELATOR
)
5084 return (E_SUB_VECTOR_LENGTH_ERROR
);
5086 *correlator
= (rsv
->svv
[0] << 8 | rsv
->svv
[1]);
5088 return (POSITIVE_ACK
);
5091 static int smctr_set_error_timer_value(struct net_device
*dev
,
5092 MAC_SUB_VECTOR
*rsv
)
5097 if(rsv
->svl
!= S_ERROR_TIMER_VALUE
)
5098 return (E_SUB_VECTOR_LENGTH_ERROR
);
5100 err_tval
= (rsv
->svv
[0] << 8 | rsv
->svv
[1])*10;
5102 smctr_issue_write_word_cmd(dev
, RW_TER_THRESHOLD
, &err_tval
);
5104 if((err
= smctr_wait_cmd(dev
)))
5107 return (POSITIVE_ACK
);
5110 static int smctr_set_frame_forward(struct net_device
*dev
,
5111 MAC_SUB_VECTOR
*rsv
, __u8 dc_sc
)
5113 if((rsv
->svl
< 2) || (rsv
->svl
> S_FRAME_FORWARD
))
5114 return (E_SUB_VECTOR_LENGTH_ERROR
);
5116 if((dc_sc
& DC_MASK
) != DC_CRS
)
5118 if(rsv
->svl
>= 2 && rsv
->svl
< 20)
5119 return (E_TRANSMIT_FORWARD_INVALID
);
5121 if((rsv
->svv
[0] != 0) || (rsv
->svv
[1] != 0))
5122 return (E_TRANSMIT_FORWARD_INVALID
);
5125 return (POSITIVE_ACK
);
5128 static int smctr_set_local_ring_num(struct net_device
*dev
,
5129 MAC_SUB_VECTOR
*rsv
)
5131 struct net_local
*tp
= netdev_priv(dev
);
5133 if(rsv
->svl
!= S_LOCAL_RING_NUMBER
)
5134 return (E_SUB_VECTOR_LENGTH_ERROR
);
5136 if(tp
->ptr_local_ring_num
)
5137 *(__u16
*)(tp
->ptr_local_ring_num
)
5138 = (rsv
->svv
[0] << 8 | rsv
->svv
[1]);
5140 return (POSITIVE_ACK
);
5143 static unsigned short smctr_set_ctrl_attention(struct net_device
*dev
)
5145 struct net_local
*tp
= netdev_priv(dev
);
5146 int ioaddr
= dev
->base_addr
;
5148 if(tp
->bic_type
== BIC_585_CHIP
)
5149 outb((tp
->trc_mask
| HWR_CA
), ioaddr
+ HWR
);
5152 outb((tp
->trc_mask
| CSR_CA
), ioaddr
+ CSR
);
5153 outb(tp
->trc_mask
, ioaddr
+ CSR
);
5159 static void smctr_set_multicast_list(struct net_device
*dev
)
5161 if(smctr_debug
> 10)
5162 printk(KERN_DEBUG
"%s: smctr_set_multicast_list\n", dev
->name
);
5167 static int smctr_set_page(struct net_device
*dev
, __u8
*buf
)
5169 struct net_local
*tp
= netdev_priv(dev
);
5173 tptr
= (__u32
)buf
- (__u32
)tp
->ram_access
;
5174 amask
= (__u8
)((tptr
& PR_PAGE_MASK
) >> 8);
5175 outb(amask
, dev
->base_addr
+ PR
);
5180 static int smctr_set_phy_drop(struct net_device
*dev
, MAC_SUB_VECTOR
*rsv
)
5184 if(rsv
->svl
!= S_PHYSICAL_DROP
)
5185 return (E_SUB_VECTOR_LENGTH_ERROR
);
5187 smctr_issue_write_byte_cmd(dev
, RW_PHYSICAL_DROP_NUMBER
, &rsv
->svv
[0]);
5188 if((err
= smctr_wait_cmd(dev
)))
5191 return (POSITIVE_ACK
);
5194 /* Reset the ring speed to the opposite of what it was. This auto-pilot
5195 * mode requires a complete reset and re-init of the adapter.
5197 static int smctr_set_ring_speed(struct net_device
*dev
)
5199 struct net_local
*tp
= netdev_priv(dev
);
5202 if(tp
->media_type
== MEDIA_UTP_16
)
5203 tp
->media_type
= MEDIA_UTP_4
;
5205 tp
->media_type
= MEDIA_UTP_16
;
5207 smctr_enable_16bit(dev
);
5209 /* Re-Initialize adapter's internal registers */
5210 smctr_reset_adapter(dev
);
5212 if((err
= smctr_init_card_real(dev
)))
5215 smctr_enable_bic_int(dev
);
5217 if((err
= smctr_issue_enable_int_cmd(dev
, TRC_INTERRUPT_ENABLE_MASK
)))
5220 smctr_disable_16bit(dev
);
5225 static int smctr_set_rx_look_ahead(struct net_device
*dev
)
5227 struct net_local
*tp
= netdev_priv(dev
);
5230 if(smctr_debug
> 10)
5231 printk(KERN_DEBUG
"%s: smctr_set_rx_look_ahead_flag\n", dev
->name
);
5233 tp
->adapter_flags
&= ~(FORCED_16BIT_MODE
);
5234 tp
->adapter_flags
|= RX_VALID_LOOKAHEAD
;
5236 if(tp
->adapter_bus
== BUS_ISA16_TYPE
)
5238 sword
= *((__u16
*)(tp
->ram_access
));
5239 *((__u16
*)(tp
->ram_access
)) = 0x1234;
5241 smctr_disable_16bit(dev
);
5242 rword
= *((__u16
*)(tp
->ram_access
));
5243 smctr_enable_16bit(dev
);
5246 tp
->adapter_flags
|= FORCED_16BIT_MODE
;
5248 *((__u16
*)(tp
->ram_access
)) = sword
;
5254 static int smctr_set_trc_reset(int ioaddr
)
5258 r
= inb(ioaddr
+ MSR
);
5259 outb(MSR_RST
| r
, ioaddr
+ MSR
);
5265 * This function can be called if the adapter is busy or not.
5267 static int smctr_setup_single_cmd(struct net_device
*dev
,
5268 __u16 command
, __u16 subcommand
)
5270 struct net_local
*tp
= netdev_priv(dev
);
5273 if(smctr_debug
> 10)
5274 printk(KERN_DEBUG
"%s: smctr_setup_single_cmd\n", dev
->name
);
5276 if((err
= smctr_wait_while_cbusy(dev
)))
5279 if((err
= (unsigned int)smctr_wait_cmd(dev
)))
5282 tp
->acb_head
->cmd_done_status
= 0;
5283 tp
->acb_head
->cmd
= command
;
5284 tp
->acb_head
->subcmd
= subcommand
;
5286 err
= smctr_issue_resume_acb_cmd(dev
);
5292 * This function can not be called with the adapter busy.
5294 static int smctr_setup_single_cmd_w_data(struct net_device
*dev
,
5295 __u16 command
, __u16 subcommand
)
5297 struct net_local
*tp
= netdev_priv(dev
);
5299 tp
->acb_head
->cmd_done_status
= ACB_COMMAND_NOT_DONE
;
5300 tp
->acb_head
->cmd
= command
;
5301 tp
->acb_head
->subcmd
= subcommand
;
5302 tp
->acb_head
->data_offset_lo
5303 = (__u16
)TRC_POINTER(tp
->misc_command_data
);
5305 return(smctr_issue_resume_acb_cmd(dev
));
5308 static char *smctr_malloc(struct net_device
*dev
, __u16 size
)
5310 struct net_local
*tp
= netdev_priv(dev
);
5313 m
= (char *)(tp
->ram_access
+ tp
->sh_mem_used
);
5314 tp
->sh_mem_used
+= (__u32
)size
;
5319 static int smctr_status_chg(struct net_device
*dev
)
5321 struct net_local
*tp
= netdev_priv(dev
);
5323 if(smctr_debug
> 10)
5324 printk(KERN_DEBUG
"%s: smctr_status_chg\n", dev
->name
);
5334 /* Interrupt driven open() completion. XXX */
5336 tp
->group_address_0
= 0;
5337 tp
->group_address
[0] = 0;
5338 tp
->group_address
[1] = 0;
5339 tp
->functional_address_0
= 0;
5340 tp
->functional_address
[0] = 0;
5341 tp
->functional_address
[1] = 0;
5346 printk(KERN_INFO
"%s: status change unknown %x\n",
5347 dev
->name
, tp
->status
);
5354 static int smctr_trc_send_packet(struct net_device
*dev
, FCBlock
*fcb
,
5357 struct net_local
*tp
= netdev_priv(dev
);
5360 if(smctr_debug
> 10)
5361 printk(KERN_DEBUG
"%s: smctr_trc_send_packet\n", dev
->name
);
5363 fcb
->info
= FCB_CHAIN_END
| FCB_ENABLE_TFS
;
5364 if(tp
->num_tx_fcbs
[queue
] != 1)
5365 fcb
->back_ptr
->info
= FCB_INTERRUPT_ENABLE
| FCB_ENABLE_TFS
;
5367 if(tp
->tx_queue_status
[queue
] == NOT_TRANSMITING
)
5369 tp
->tx_queue_status
[queue
] = TRANSMITING
;
5370 err
= smctr_issue_resume_tx_fcb_cmd(dev
, queue
);
5376 static __u16
smctr_tx_complete(struct net_device
*dev
, __u16 queue
)
5378 struct net_local
*tp
= netdev_priv(dev
);
5379 __u16 status
, err
= 0;
5382 if(smctr_debug
> 10)
5383 printk(KERN_DEBUG
"%s: smctr_tx_complete\n", dev
->name
);
5385 while((status
= tp
->tx_fcb_end
[queue
]->frame_status
) != SUCCESS
)
5387 if(status
& 0x7e00 )
5389 err
= HARDWARE_FAILED
;
5393 if((err
= smctr_update_tx_chain(dev
, tp
->tx_fcb_end
[queue
],
5397 smctr_disable_16bit(dev
);
5399 if(tp
->mode_bits
& UMAC
)
5401 if(!(status
& (FCB_TX_STATUS_AR1
| FCB_TX_STATUS_AR2
)))
5402 cstatus
= NO_SUCH_DESTINATION
;
5405 if(!(status
& (FCB_TX_STATUS_CR1
| FCB_TX_STATUS_CR2
)))
5406 cstatus
= DEST_OUT_OF_RESOURCES
;
5409 if(status
& FCB_TX_STATUS_E
)
5410 cstatus
= MAX_COLLISIONS
;
5419 if(queue
== BUG_QUEUE
)
5422 smctr_enable_16bit(dev
);
5430 static unsigned short smctr_tx_move_frame(struct net_device
*dev
,
5431 struct sk_buff
*skb
, __u8
*pbuff
, unsigned int bytes
)
5433 struct net_local
*tp
= netdev_priv(dev
);
5434 unsigned int ram_usable
;
5435 __u32 flen
, len
, offset
= 0;
5438 if(smctr_debug
> 10)
5439 printk(KERN_DEBUG
"%s: smctr_tx_move_frame\n", dev
->name
);
5441 ram_usable
= ((unsigned int)tp
->ram_usable
) << 10;
5445 while(flen
> 0 && bytes
> 0)
5447 smctr_set_page(dev
, pbuff
);
5449 offset
= SMC_PAGE_OFFSET(pbuff
);
5451 if(offset
+ flen
> ram_usable
)
5452 len
= ram_usable
- offset
;
5459 page
= (char *) (offset
+ tp
->ram_access
);
5460 memcpy(page
, frag
, len
);
5471 /* Update the error statistic counters for this adapter. */
5472 static int smctr_update_err_stats(struct net_device
*dev
)
5474 struct net_local
*tp
= netdev_priv(dev
);
5475 struct tr_statistics
*tstat
= &tp
->MacStat
;
5477 if(tstat
->internal_errors
)
5478 tstat
->internal_errors
5479 += *(tp
->misc_command_data
+ 0) & 0x00ff;
5481 if(tstat
->line_errors
)
5482 tstat
->line_errors
+= *(tp
->misc_command_data
+ 0) >> 8;
5484 if(tstat
->A_C_errors
)
5485 tstat
->A_C_errors
+= *(tp
->misc_command_data
+ 1) & 0x00ff;
5487 if(tstat
->burst_errors
)
5488 tstat
->burst_errors
+= *(tp
->misc_command_data
+ 1) >> 8;
5490 if(tstat
->abort_delimiters
)
5491 tstat
->abort_delimiters
+= *(tp
->misc_command_data
+ 2) >> 8;
5493 if(tstat
->recv_congest_count
)
5494 tstat
->recv_congest_count
5495 += *(tp
->misc_command_data
+ 3) & 0x00ff;
5497 if(tstat
->lost_frames
)
5499 += *(tp
->misc_command_data
+ 3) >> 8;
5501 if(tstat
->frequency_errors
)
5502 tstat
->frequency_errors
+= *(tp
->misc_command_data
+ 4) & 0x00ff;
5504 if(tstat
->frame_copied_errors
)
5505 tstat
->frame_copied_errors
5506 += *(tp
->misc_command_data
+ 4) >> 8;
5508 if(tstat
->token_errors
)
5509 tstat
->token_errors
+= *(tp
->misc_command_data
+ 5) >> 8;
5514 static int smctr_update_rx_chain(struct net_device
*dev
, __u16 queue
)
5516 struct net_local
*tp
= netdev_priv(dev
);
5521 fcb
= tp
->rx_fcb_curr
[queue
];
5522 len
= fcb
->frame_length
;
5524 fcb
->frame_status
= 0;
5525 fcb
->info
= FCB_CHAIN_END
;
5526 fcb
->back_ptr
->info
= FCB_WARNING
;
5528 tp
->rx_fcb_curr
[queue
] = tp
->rx_fcb_curr
[queue
]->next_ptr
;
5530 /* update RX BDBs */
5531 size
= (len
>> RX_BDB_SIZE_SHIFT
);
5532 if(len
& RX_DATA_BUFFER_SIZE_MASK
)
5533 size
+= sizeof(BDBlock
);
5534 size
&= (~RX_BDB_SIZE_MASK
);
5536 /* check if wrap around */
5537 bdb
= (BDBlock
*)((__u32
)(tp
->rx_bdb_curr
[queue
]) + (__u32
)(size
));
5538 if((__u32
)bdb
>= (__u32
)tp
->rx_bdb_end
[queue
])
5540 bdb
= (BDBlock
*)((__u32
)(tp
->rx_bdb_head
[queue
])
5541 + (__u32
)(bdb
) - (__u32
)(tp
->rx_bdb_end
[queue
]));
5544 bdb
->back_ptr
->info
= BDB_CHAIN_END
;
5545 tp
->rx_bdb_curr
[queue
]->back_ptr
->info
= BDB_NOT_CHAIN_END
;
5546 tp
->rx_bdb_curr
[queue
] = bdb
;
5551 static int smctr_update_tx_chain(struct net_device
*dev
, FCBlock
*fcb
,
5554 struct net_local
*tp
= netdev_priv(dev
);
5556 if(smctr_debug
> 20)
5557 printk(KERN_DEBUG
"smctr_update_tx_chain\n");
5559 if(tp
->num_tx_fcbs_used
[queue
] <= 0)
5560 return (HARDWARE_FAILED
);
5563 if(tp
->tx_buff_used
[queue
] < fcb
->memory_alloc
)
5565 tp
->tx_buff_used
[queue
] = 0;
5566 return (HARDWARE_FAILED
);
5569 tp
->tx_buff_used
[queue
] -= fcb
->memory_alloc
;
5571 /* if all transmit buffer are cleared
5572 * need to set the tx_buff_curr[] to tx_buff_head[]
5573 * otherwise, tx buffer will be segregate and cannot
5574 * accommodate and buffer greater than (curr - head) and
5575 * (end - curr) since we do not allow wrap around allocation.
5577 if(tp
->tx_buff_used
[queue
] == 0)
5578 tp
->tx_buff_curr
[queue
] = tp
->tx_buff_head
[queue
];
5580 tp
->num_tx_fcbs_used
[queue
]--;
5581 fcb
->frame_status
= 0;
5582 tp
->tx_fcb_end
[queue
] = fcb
->next_ptr
;
5583 netif_wake_queue(dev
);
5588 static int smctr_wait_cmd(struct net_device
*dev
)
5590 struct net_local
*tp
= netdev_priv(dev
);
5591 unsigned int loop_count
= 0x20000;
5593 if(smctr_debug
> 10)
5594 printk(KERN_DEBUG
"%s: smctr_wait_cmd\n", dev
->name
);
5598 if(tp
->acb_head
->cmd_done_status
& ACB_COMMAND_DONE
)
5605 return(HARDWARE_FAILED
);
5607 if(tp
->acb_head
->cmd_done_status
& 0xff)
5608 return(HARDWARE_FAILED
);
5613 static int smctr_wait_while_cbusy(struct net_device
*dev
)
5615 struct net_local
*tp
= netdev_priv(dev
);
5616 unsigned int timeout
= 0x20000;
5617 int ioaddr
= dev
->base_addr
;
5620 if(tp
->bic_type
== BIC_585_CHIP
)
5624 r
= inb(ioaddr
+ HWR
);
5625 if((r
& HWR_CBUSY
) == 0)
5634 r
= inb(ioaddr
+ CSR
);
5635 if((r
& CSR_CBUSY
) == 0)
5644 return (HARDWARE_FAILED
);
5649 static struct net_device
* dev_smctr
[SMCTR_MAX_ADAPTERS
];
5650 static int io
[SMCTR_MAX_ADAPTERS
];
5651 static int irq
[SMCTR_MAX_ADAPTERS
];
5653 MODULE_LICENSE("GPL");
5655 module_param_array(io
, int, NULL
, 0);
5656 module_param_array(irq
, int, NULL
, 0);
5657 module_param(ringspeed
, int, 0);
5659 static struct net_device
* __init
setup_card(int n
)
5661 struct net_device
*dev
= alloc_trdev(sizeof(struct net_local
));
5665 return ERR_PTR(-ENOMEM
);
5668 err
= smctr_probe1(dev
, io
[n
]);
5672 err
= register_netdev(dev
);
5677 #ifdef CONFIG_MCA_LEGACY
5678 { struct net_local
*tp
= netdev_priv(dev
);
5680 mca_mark_as_unused(tp
->slot_num
);
5683 release_region(dev
->base_addr
, SMCTR_IO_EXTENT
);
5684 free_irq(dev
->irq
, dev
);
5687 return ERR_PTR(err
);
5690 int __init
init_module(void)
5693 struct net_device
*dev
;
5695 for(i
= 0; i
< SMCTR_MAX_ADAPTERS
; i
++) {
5696 dev
= io
[0]? setup_card(i
) : smctr_probe(-1);
5703 return found
? 0 : -ENODEV
;
5706 void __exit
cleanup_module(void)
5710 for(i
= 0; i
< SMCTR_MAX_ADAPTERS
; i
++) {
5711 struct net_device
*dev
= dev_smctr
[i
];
5715 unregister_netdev(dev
);
5716 #ifdef CONFIG_MCA_LEGACY
5717 { struct net_local
*tp
= netdev_priv(dev
);
5719 mca_mark_as_unused(tp
->slot_num
);
5722 release_region(dev
->base_addr
, SMCTR_IO_EXTENT
);
5724 free_irq(dev
->irq
, dev
);