/[dynamips]/trunk/dev_dec21140.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/dev_dec21140.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

upstream/dynamips-0.2.7/dev_dec21140.c revision 10 by dpavlin, Sat Oct 6 16:29:14 2007 UTC upstream/dynamips-0.2.8-RC1/dev_dec21140.c revision 11 by dpavlin, Sat Oct 6 16:33:40 2007 UTC
# Line 187  struct dec21140_data { Line 187  struct dec21140_data {
187  /* Log a dec21140 message */  /* Log a dec21140 message */
188  #define DEC21140_LOG(d,msg...) vm_log((d)->vm,(d)->name,msg)  #define DEC21140_LOG(d,msg...) vm_log((d)->vm,(d)->name,msg)
189    
 /*  
  * ISL rewrite.  
  *  
  * See: http://www.cisco.com/en/US/tech/tk389/tk390/technologies_tech_note09186a0080094665.shtml  
  */  
 static void dec21140_isl_rewrite(m_uint8_t *pkt,m_uint32_t tot_len)  
 {  
    static m_uint8_t isl_xaddr[N_ETH_ALEN] = { 0x01,0x00,0x0c,0x00,0x10,0x00 };  
    u_int real_offset,real_len;  
    n_eth_hdr_t *hdr;  
    m_uint32_t ifcs;  
   
    hdr = (n_eth_hdr_t *)pkt;  
    if (!memcmp(&hdr->daddr,isl_xaddr,N_ETH_ALEN)) {  
       real_offset = N_ETH_HLEN + N_ISL_HDR_SIZE;  
       real_len    = ntohs(hdr->type);  
       real_len    -= (N_ISL_HDR_SIZE + 4);  
     
       if ((real_offset+real_len) > tot_len)  
          return;  
     
       /* Rewrite the destination MAC address */  
       hdr->daddr.eth_addr_byte[4] = 0x00;  
   
       /* Compute the internal FCS on the encapsulated packet */  
       ifcs = crc32_compute(0xFFFFFFFF,pkt+real_offset,real_len);  
       pkt[tot_len-4] = ifcs & 0xff;  
       pkt[tot_len-3] = (ifcs >> 8) & 0xff;  
       pkt[tot_len-2] = (ifcs >> 16) & 0xff;  
       pkt[tot_len-1] = ifcs >> 24;  
    }  
 }  
   
190  /* Check if a packet must be delivered to the emulated chip */  /* Check if a packet must be delivered to the emulated chip */
191  static inline int dec21140_handle_mac_addr(struct dec21140_data *d,  static inline int dec21140_handle_mac_addr(struct dec21140_data *d,
192                                             m_uint8_t *pkt)                                             m_uint8_t *pkt)
# Line 436  static inline void dev_dec21140_update_i Line 403  static inline void dev_dec21140_update_i
403     }     }
404    
405     d->csr[5] = csr5;     d->csr[5] = csr5;
406      
407     if (trigger)     if (trigger)
408        pci_dev_trigger_irq(d->vm,d->pci_dev);        pci_dev_trigger_irq(d->vm,d->pci_dev);
409     else     else
410        pci_dev_clear_irq(d->vm,d->pci_dev);        pci_dev_clear_irq(d->vm,d->pci_dev);
411  }  }
412    
# Line 872  static int dev_dec21140_handle_txring_si Line 839  static int dev_dec21140_handle_txring_si
839        mem_dump(log_file,pkt,tot_len);        mem_dump(log_file,pkt,tot_len);
840  #endif  #endif
841        /* rewrite ISL header if required */        /* rewrite ISL header if required */
842        dec21140_isl_rewrite(pkt,tot_len);        cisco_isl_rewrite(pkt,tot_len);
843    
844        /* send it on wire */        /* send it on wire */
845        netio_send(d->nio,pkt,tot_len);        netio_send(d->nio,pkt,tot_len);
# Line 881  static int dev_dec21140_handle_txring_si Line 848  static int dev_dec21140_handle_txring_si
848   clear_txd0_own_bit:   clear_txd0_own_bit:
849     /* Clear the OWN flag of the first descriptor */     /* Clear the OWN flag of the first descriptor */
850     physmem_copy_u32_to_vm(d->vm,tx_start,0);     physmem_copy_u32_to_vm(d->vm,tx_start,0);
851      
852     /* Interrupt on completion ? */     /* Interrupt on completion ? */
853     if (txd0.tdes[1] & DEC21140_TXDESC_IC) {     if (txd0.tdes[1] & DEC21140_TXDESC_IC) {      
854        d->csr[5] |= DEC21140_CSR5_TI;        d->csr[5] |= DEC21140_CSR5_TI;
855        dev_dec21140_update_irq_status(d);        dev_dec21140_update_irq_status(d);
856     }     }

Legend:
Removed from v.10  
changed lines
  Added in v.11

  ViewVC Help
Powered by ViewVC 1.1.26