diff options
Diffstat (limited to 'drivers/net/tokenring/smctr.c')
-rw-r--r-- | drivers/net/tokenring/smctr.c | 89 |
1 files changed, 43 insertions, 46 deletions
diff --git a/drivers/net/tokenring/smctr.c b/drivers/net/tokenring/smctr.c index ebda61bc4c2f..e40560137c46 100644 --- a/drivers/net/tokenring/smctr.c +++ b/drivers/net/tokenring/smctr.c | |||
@@ -36,7 +36,6 @@ | |||
36 | #include <linux/ptrace.h> | 36 | #include <linux/ptrace.h> |
37 | #include <linux/ioport.h> | 37 | #include <linux/ioport.h> |
38 | #include <linux/in.h> | 38 | #include <linux/in.h> |
39 | #include <linux/slab.h> | ||
40 | #include <linux/string.h> | 39 | #include <linux/string.h> |
41 | #include <linux/time.h> | 40 | #include <linux/time.h> |
42 | #include <linux/errno.h> | 41 | #include <linux/errno.h> |
@@ -426,7 +425,7 @@ static int smctr_alloc_shared_memory(struct net_device *dev) | |||
426 | smctr_malloc(dev, 1L); | 425 | smctr_malloc(dev, 1L); |
427 | 426 | ||
428 | /* Allocate Non-MAC receive data buffers. | 427 | /* Allocate Non-MAC receive data buffers. |
429 | * To guarantee a minimum of 256 contigous memory to | 428 | * To guarantee a minimum of 256 contiguous memory to |
430 | * UM_Receive_Packet's lookahead pointer, before a page | 429 | * UM_Receive_Packet's lookahead pointer, before a page |
431 | * change or ring end is encountered, place each rx buffer on | 430 | * change or ring end is encountered, place each rx buffer on |
432 | * a 256 byte boundary. | 431 | * a 256 byte boundary. |
@@ -2309,9 +2308,9 @@ static irqreturn_t smctr_interrupt(int irq, void *dev_id) | |||
2309 | else | 2308 | else |
2310 | { | 2309 | { |
2311 | if((tp->acb_head->cmd | 2310 | if((tp->acb_head->cmd |
2312 | == ACB_CMD_READ_TRC_STATUS) | 2311 | == ACB_CMD_READ_TRC_STATUS) && |
2313 | && (tp->acb_head->subcmd | 2312 | (tp->acb_head->subcmd |
2314 | == RW_TRC_STATUS_BLOCK)) | 2313 | == RW_TRC_STATUS_BLOCK)) |
2315 | { | 2314 | { |
2316 | if(tp->ptr_bcn_type) | 2315 | if(tp->ptr_bcn_type) |
2317 | { | 2316 | { |
@@ -2331,8 +2330,8 @@ static irqreturn_t smctr_interrupt(int irq, void *dev_id) | |||
2331 | smctr_disable_16bit(dev); | 2330 | smctr_disable_16bit(dev); |
2332 | err = smctr_ring_status_chg(dev); | 2331 | err = smctr_ring_status_chg(dev); |
2333 | smctr_enable_16bit(dev); | 2332 | smctr_enable_16bit(dev); |
2334 | if((tp->ring_status & REMOVE_RECEIVED) | 2333 | if((tp->ring_status & REMOVE_RECEIVED) && |
2335 | && (tp->config_word0 & NO_AUTOREMOVE)) | 2334 | (tp->config_word0 & NO_AUTOREMOVE)) |
2336 | { | 2335 | { |
2337 | smctr_issue_remove_cmd(dev); | 2336 | smctr_issue_remove_cmd(dev); |
2338 | } | 2337 | } |
@@ -2511,9 +2510,9 @@ static int smctr_issue_init_timers_cmd(struct net_device *dev) | |||
2511 | tp->config_word0 = THDREN | DMA_TRIGGER | USETPT | NO_AUTOREMOVE; | 2510 | tp->config_word0 = THDREN | DMA_TRIGGER | USETPT | NO_AUTOREMOVE; |
2512 | tp->config_word1 = 0; | 2511 | tp->config_word1 = 0; |
2513 | 2512 | ||
2514 | if((tp->media_type == MEDIA_STP_16) | 2513 | if((tp->media_type == MEDIA_STP_16) || |
2515 | || (tp->media_type == MEDIA_UTP_16) | 2514 | (tp->media_type == MEDIA_UTP_16) || |
2516 | || (tp->media_type == MEDIA_STP_16_UTP_16)) | 2515 | (tp->media_type == MEDIA_STP_16_UTP_16)) |
2517 | { | 2516 | { |
2518 | tp->config_word0 |= FREQ_16MB_BIT; | 2517 | tp->config_word0 |= FREQ_16MB_BIT; |
2519 | } | 2518 | } |
@@ -2556,9 +2555,9 @@ static int smctr_issue_init_timers_cmd(struct net_device *dev) | |||
2556 | tp->config_word1 &= ~SOURCE_ROUTING_SPANNING_BITS; | 2555 | tp->config_word1 &= ~SOURCE_ROUTING_SPANNING_BITS; |
2557 | } | 2556 | } |
2558 | 2557 | ||
2559 | if((tp->media_type == MEDIA_STP_16) | 2558 | if((tp->media_type == MEDIA_STP_16) || |
2560 | || (tp->media_type == MEDIA_UTP_16) | 2559 | (tp->media_type == MEDIA_UTP_16) || |
2561 | || (tp->media_type == MEDIA_STP_16_UTP_16)) | 2560 | (tp->media_type == MEDIA_STP_16_UTP_16)) |
2562 | { | 2561 | { |
2563 | tp->config_word1 |= INTERFRAME_SPACING_16; | 2562 | tp->config_word1 |= INTERFRAME_SPACING_16; |
2564 | } | 2563 | } |
@@ -2568,9 +2567,9 @@ static int smctr_issue_init_timers_cmd(struct net_device *dev) | |||
2568 | *pTimer_Struc++ = tp->config_word0; | 2567 | *pTimer_Struc++ = tp->config_word0; |
2569 | *pTimer_Struc++ = tp->config_word1; | 2568 | *pTimer_Struc++ = tp->config_word1; |
2570 | 2569 | ||
2571 | if((tp->media_type == MEDIA_STP_4) | 2570 | if((tp->media_type == MEDIA_STP_4) || |
2572 | || (tp->media_type == MEDIA_UTP_4) | 2571 | (tp->media_type == MEDIA_UTP_4) || |
2573 | || (tp->media_type == MEDIA_STP_4_UTP_4)) | 2572 | (tp->media_type == MEDIA_STP_4_UTP_4)) |
2574 | { | 2573 | { |
2575 | *pTimer_Struc++ = 0x00FA; /* prescale */ | 2574 | *pTimer_Struc++ = 0x00FA; /* prescale */ |
2576 | *pTimer_Struc++ = 0x2710; /* TPT_limit */ | 2575 | *pTimer_Struc++ = 0x2710; /* TPT_limit */ |
@@ -2990,8 +2989,8 @@ static int smctr_load_firmware(struct net_device *dev) | |||
2990 | } | 2989 | } |
2991 | 2990 | ||
2992 | /* Verify the firmware exists and is there in the right amount. */ | 2991 | /* Verify the firmware exists and is there in the right amount. */ |
2993 | if (!fw->data | 2992 | if (!fw->data || |
2994 | || (*(fw->data + UCODE_VERSION_OFFSET) < UCODE_VERSION)) | 2993 | (*(fw->data + UCODE_VERSION_OFFSET) < UCODE_VERSION)) |
2995 | { | 2994 | { |
2996 | err = (UCODE_NOT_PRESENT); | 2995 | err = (UCODE_NOT_PRESENT); |
2997 | goto out; | 2996 | goto out; |
@@ -3010,9 +3009,8 @@ static int smctr_load_firmware(struct net_device *dev) | |||
3010 | smctr_enable_16bit(dev); | 3009 | smctr_enable_16bit(dev); |
3011 | smctr_set_page(dev, (__u8 *)tp->ram_access); | 3010 | smctr_set_page(dev, (__u8 *)tp->ram_access); |
3012 | 3011 | ||
3013 | if((smctr_checksum_firmware(dev)) | 3012 | if((smctr_checksum_firmware(dev)) || |
3014 | || (*(fw->data + UCODE_VERSION_OFFSET) | 3013 | (*(fw->data + UCODE_VERSION_OFFSET) > tp->microcode_version)) |
3015 | > tp->microcode_version)) | ||
3016 | { | 3014 | { |
3017 | smctr_enable_adapter_ctrl_store(dev); | 3015 | smctr_enable_adapter_ctrl_store(dev); |
3018 | 3016 | ||
@@ -3117,9 +3115,9 @@ static int smctr_lobe_media_test(struct net_device *dev) | |||
3117 | } | 3115 | } |
3118 | 3116 | ||
3119 | /* Check if any frames received during test. */ | 3117 | /* Check if any frames received during test. */ |
3120 | if((tp->rx_fcb_curr[MAC_QUEUE]->frame_status) | 3118 | if((tp->rx_fcb_curr[MAC_QUEUE]->frame_status) || |
3121 | || (tp->rx_fcb_curr[NON_MAC_QUEUE]->frame_status)) | 3119 | (tp->rx_fcb_curr[NON_MAC_QUEUE]->frame_status)) |
3122 | goto err; | 3120 | goto err; |
3123 | 3121 | ||
3124 | /* Set receive mask to "Promisc" mode. */ | 3122 | /* Set receive mask to "Promisc" mode. */ |
3125 | tp->receive_mask = saved_rcv_mask; | 3123 | tp->receive_mask = saved_rcv_mask; |
@@ -3303,8 +3301,8 @@ static int smctr_make_group_addr(struct net_device *dev, MAC_SUB_VECTOR *tsv) | |||
3303 | /* Set Group Address Sub-vector to all zeros if only the | 3301 | /* Set Group Address Sub-vector to all zeros if only the |
3304 | * Group Address/Functional Address Indicator is set. | 3302 | * Group Address/Functional Address Indicator is set. |
3305 | */ | 3303 | */ |
3306 | if(tsv->svv[0] == 0x80 && tsv->svv[1] == 0x00 | 3304 | if(tsv->svv[0] == 0x80 && tsv->svv[1] == 0x00 && |
3307 | && tsv->svv[2] == 0x00 && tsv->svv[3] == 0x00) | 3305 | tsv->svv[2] == 0x00 && tsv->svv[3] == 0x00) |
3308 | tsv->svv[0] = 0x00; | 3306 | tsv->svv[0] = 0x00; |
3309 | 3307 | ||
3310 | return (0); | 3308 | return (0); |
@@ -3876,10 +3874,10 @@ static int smctr_process_rx_packet(MAC_HEADER *rmf, __u16 size, | |||
3876 | /* NOTE: UNKNOWN MAC frames will NOT be passed up unless | 3874 | /* NOTE: UNKNOWN MAC frames will NOT be passed up unless |
3877 | * ACCEPT_ATT_MAC_FRAMES is set. | 3875 | * ACCEPT_ATT_MAC_FRAMES is set. |
3878 | */ | 3876 | */ |
3879 | if(((tp->receive_mask & ACCEPT_ATT_MAC_FRAMES) | 3877 | if(((tp->receive_mask & ACCEPT_ATT_MAC_FRAMES) && |
3880 | && (xframe == (__u8)0)) | 3878 | (xframe == (__u8)0)) || |
3881 | || ((tp->receive_mask & ACCEPT_EXT_MAC_FRAMES) | 3879 | ((tp->receive_mask & ACCEPT_EXT_MAC_FRAMES) && |
3882 | && (xframe == (__u8)1))) | 3880 | (xframe == (__u8)1))) |
3883 | { | 3881 | { |
3884 | rmf->vl = SWAP_BYTES(rmf->vl); | 3882 | rmf->vl = SWAP_BYTES(rmf->vl); |
3885 | 3883 | ||
@@ -3934,8 +3932,8 @@ static int smctr_ram_memory_test(struct net_device *dev) | |||
3934 | 3932 | ||
3935 | word_pattern = start_pattern; | 3933 | word_pattern = start_pattern; |
3936 | 3934 | ||
3937 | for(j = 1; j < (__u32)(tp->ram_usable * 1024) - 1 | 3935 | for(j = 1; j < (__u32)(tp->ram_usable * 1024) - 1 && (~err); |
3938 | && (~err); j += 2, word_pattern++) | 3936 | j += 2, word_pattern++) |
3939 | { | 3937 | { |
3940 | word_read = *(__u16 *)(pword + j); | 3938 | word_read = *(__u16 *)(pword + j); |
3941 | if(word_read != word_pattern) | 3939 | if(word_read != word_pattern) |
@@ -3959,8 +3957,7 @@ static int smctr_ram_memory_test(struct net_device *dev) | |||
3959 | for(j = 0; j < (__u32)tp->ram_usable * 1024; j +=2) | 3957 | for(j = 0; j < (__u32)tp->ram_usable * 1024; j +=2) |
3960 | *(__u16 *)(pword + j) = word_pattern; | 3958 | *(__u16 *)(pword + j) = word_pattern; |
3961 | 3959 | ||
3962 | for(j =0; j < (__u32)tp->ram_usable * 1024 | 3960 | for(j =0; j < (__u32)tp->ram_usable * 1024 && (~err); j += 2) |
3963 | && (~err); j += 2) | ||
3964 | { | 3961 | { |
3965 | word_read = *(__u16 *)(pword + j); | 3962 | word_read = *(__u16 *)(pword + j); |
3966 | if(word_read != word_pattern) | 3963 | if(word_read != word_pattern) |
@@ -4325,8 +4322,8 @@ static int smctr_restart_tx_chain(struct net_device *dev, short queue) | |||
4325 | if(smctr_debug > 10) | 4322 | if(smctr_debug > 10) |
4326 | printk(KERN_DEBUG "%s: smctr_restart_tx_chain\n", dev->name); | 4323 | printk(KERN_DEBUG "%s: smctr_restart_tx_chain\n", dev->name); |
4327 | 4324 | ||
4328 | if(tp->num_tx_fcbs_used[queue] != 0 | 4325 | if(tp->num_tx_fcbs_used[queue] != 0 && |
4329 | && tp->tx_queue_status[queue] == NOT_TRANSMITING) | 4326 | tp->tx_queue_status[queue] == NOT_TRANSMITING) |
4330 | { | 4327 | { |
4331 | tp->tx_queue_status[queue] = TRANSMITING; | 4328 | tp->tx_queue_status[queue] = TRANSMITING; |
4332 | err = smctr_issue_resume_tx_fcb_cmd(dev, queue); | 4329 | err = smctr_issue_resume_tx_fcb_cmd(dev, queue); |
@@ -4349,8 +4346,8 @@ static int smctr_ring_status_chg(struct net_device *dev) | |||
4349 | */ | 4346 | */ |
4350 | if(tp->ring_status_flags == MONITOR_STATE_CHANGED) | 4347 | if(tp->ring_status_flags == MONITOR_STATE_CHANGED) |
4351 | { | 4348 | { |
4352 | if((tp->monitor_state == MS_ACTIVE_MONITOR_STATE) | 4349 | if((tp->monitor_state == MS_ACTIVE_MONITOR_STATE) || |
4353 | || (tp->monitor_state == MS_STANDBY_MONITOR_STATE)) | 4350 | (tp->monitor_state == MS_STANDBY_MONITOR_STATE)) |
4354 | { | 4351 | { |
4355 | tp->monitor_state_ready = 1; | 4352 | tp->monitor_state_ready = 1; |
4356 | } | 4353 | } |
@@ -4363,8 +4360,8 @@ static int smctr_ring_status_chg(struct net_device *dev) | |||
4363 | tp->monitor_state_ready = 0; | 4360 | tp->monitor_state_ready = 0; |
4364 | 4361 | ||
4365 | /* Ring speed problem, switching to auto mode. */ | 4362 | /* Ring speed problem, switching to auto mode. */ |
4366 | if(tp->monitor_state == MS_MONITOR_FSM_INACTIVE | 4363 | if(tp->monitor_state == MS_MONITOR_FSM_INACTIVE && |
4367 | && !tp->cleanup) | 4364 | !tp->cleanup) |
4368 | { | 4365 | { |
4369 | printk(KERN_INFO "%s: Incorrect ring speed switching.\n", | 4366 | printk(KERN_INFO "%s: Incorrect ring speed switching.\n", |
4370 | dev->name); | 4367 | dev->name); |
@@ -4442,8 +4439,8 @@ static int smctr_rx_frame(struct net_device *dev) | |||
4442 | { | 4439 | { |
4443 | err = HARDWARE_FAILED; | 4440 | err = HARDWARE_FAILED; |
4444 | 4441 | ||
4445 | if(((status & 0x007f) == 0) | 4442 | if(((status & 0x007f) == 0) || |
4446 | || ((tp->receive_mask & ACCEPT_ERR_PACKETS) != 0)) | 4443 | ((tp->receive_mask & ACCEPT_ERR_PACKETS) != 0)) |
4447 | { | 4444 | { |
4448 | /* frame length less the CRC (4 bytes) + FS (1 byte) */ | 4445 | /* frame length less the CRC (4 bytes) + FS (1 byte) */ |
4449 | rx_size = tp->rx_fcb_curr[queue]->frame_length - 5; | 4446 | rx_size = tp->rx_fcb_curr[queue]->frame_length - 5; |
@@ -4538,8 +4535,8 @@ static int smctr_send_dat(struct net_device *dev) | |||
4538 | } | 4535 | } |
4539 | 4536 | ||
4540 | /* Check if GOOD frame Tx'ed. */ | 4537 | /* Check if GOOD frame Tx'ed. */ |
4541 | if(!(fcb->frame_status & FCB_COMMAND_DONE) | 4538 | if(!(fcb->frame_status & FCB_COMMAND_DONE) || |
4542 | || fcb->frame_status & (FCB_TX_STATUS_E | FCB_TX_AC_BITS)) | 4539 | fcb->frame_status & (FCB_TX_STATUS_E | FCB_TX_AC_BITS)) |
4543 | { | 4540 | { |
4544 | return (INITIALIZE_FAILED); | 4541 | return (INITIALIZE_FAILED); |
4545 | } | 4542 | } |
@@ -4653,8 +4650,8 @@ static int smctr_send_lobe_media_test(struct net_device *dev) | |||
4653 | } | 4650 | } |
4654 | 4651 | ||
4655 | /* Check if GOOD frame Tx'ed */ | 4652 | /* Check if GOOD frame Tx'ed */ |
4656 | if(!(fcb->frame_status & FCB_COMMAND_DONE) | 4653 | if(!(fcb->frame_status & FCB_COMMAND_DONE) || |
4657 | || fcb->frame_status & (FCB_TX_STATUS_E | FCB_TX_AC_BITS)) | 4654 | fcb->frame_status & (FCB_TX_STATUS_E | FCB_TX_AC_BITS)) |
4658 | { | 4655 | { |
4659 | return (LOBE_MEDIA_TEST_FAILED); | 4656 | return (LOBE_MEDIA_TEST_FAILED); |
4660 | } | 4657 | } |