patch-2.2.16 linux/drivers/net/olympic.c
Next file: linux/drivers/net/olympic.h
Previous file: linux/drivers/net/n2.c
Back to the patch index
Back to the overall index
- Lines: 312
- Date:
Wed Jun 7 14:26:43 2000
- Orig file:
v2.2.15/linux/drivers/net/olympic.c
- Orig date:
Wed May 3 17:16:41 2000
diff -urN v2.2.15/linux/drivers/net/olympic.c linux/drivers/net/olympic.c
@@ -24,7 +24,18 @@
* Merged into the kernel code
*
* 3/10/00 - Enabled FDX and fixed bugs produced thereafter.
- * Put in smp code
+ * Put in smp code
+ *
+ * 5/20/00 - Changes to handle Olympic on LinuxPPC. Endian changes.
+ * The odd thing about the changes is that the fix for
+ * endian issues with the big-endian data in the arb, asb...
+ * was to always swab() the bytes, no matter what CPU.
+ * That's because the read[wl]() functions always swap the
+ * bytes on the way in on PPC.
+ * Fixing the hardware descriptors was another matter,
+ * because they weren't going through read[wl](), there all
+ * the results had to be in memory in le32 values. kdaaker
+ *
* To Do:
*
* If Problems do Occur
@@ -164,7 +175,15 @@
if (pci_present()) {
while((pci_device=pci_find_device(PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_TR_WAKE, pci_device))) {
+ u16 pci_command;
+ /* PCI Spec 2.1 states that it is either the driver or PCI card's
+ * responsibility to set the PCI Master Enable Bit if needed.
+ * (From Mark Stockton <marks@schooner.sys.hou.compaq.com>)
+ */
+ pci_read_config_word(pci_device, PCI_COMMAND, &pci_command);
+ pci_command |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
+ pci_write_config_word(pci_device, PCI_COMMAND, pci_command);
pci_set_master(pci_device);
/* Check to see if io has been allocated, if so, we've already done this card,
@@ -314,14 +333,14 @@
return -1;
}
- uaa_addr=ntohs(readw(init_srb+8));
+ uaa_addr=swab16(readw(init_srb+8));
#if OLYMPIC_DEBUG
printk("UAA resides at %x\n",uaa_addr);
#endif
- writel(uaa_addr,olympic_mmio+LAPA);
- adapter_addr=olympic_priv->olympic_lap + (uaa_addr & (~0xf800));
+ writel(uaa_addr, olympic_mmio+LAPA);
+ adapter_addr = olympic_priv->olympic_lap + (uaa_addr & (~0xf800));
#if OLYMPIC_DEBUG
printk("adapter address: %02x:%02x:%02x:%02x:%02x:%02x\n",
@@ -331,8 +350,8 @@
memcpy_fromio(&dev->dev_addr[0], adapter_addr,6);
- olympic_priv->olympic_addr_table_addr = ntohs(readw(init_srb + 12)) ;
- olympic_priv->olympic_parms_addr = ntohs(readw(init_srb + 14)) ;
+ olympic_priv->olympic_addr_table_addr = swab16(readw(init_srb + 12));
+ olympic_priv->olympic_parms_addr = swab16(readw(init_srb + 14));
return 0;
@@ -394,9 +413,9 @@
/* If Network Monitor, instruct card to copy MAC frames through the ARB */
#if OLYMPIC_NETWORK_MONITOR
- writew(ntohs(OPEN_ADAPTER_ENABLE_FDX | OPEN_ADAPTER_PASS_ADC_MAC | OPEN_ADAPTER_PASS_ATT_MAC | OPEN_ADAPTER_PASS_BEACON),init_srb+8);
+ writew(swab16(OPEN_ADAPTER_ENABLE_FDX | OPEN_ADAPTER_PASS_ADC_MAC | OPEN_ADAPTER_PASS_ATT_MAC | OPEN_ADAPTER_PASS_BEACON), init_srb+8);
#else
- writew(ntohs(OPEN_ADAPTER_ENABLE_FDX),init_srb+8);
+ writew(swab16(OPEN_ADAPTER_ENABLE_FDX), init_srb+8);
#endif
if (olympic_priv->olympic_laa[0]) {
@@ -430,7 +449,7 @@
#if OLYMPIC_DEBUG
printk("init_srb(%p): ",init_srb);
for(i=0;i<20;i++)
- printk("%x ",readb(init_srb+i));
+ printk("%02x ",readb(init_srb+i));
printk("\n");
#endif
@@ -489,10 +508,10 @@
if (olympic_priv->olympic_message_level)
printk(KERN_INFO "%s: Opened in %d Mbps mode\n",dev->name, olympic_priv->olympic_ring_speed);
- olympic_priv->asb=ntohs(readw(init_srb+8));
- olympic_priv->srb=ntohs(readw(init_srb+10));
- olympic_priv->arb=ntohs(readw(init_srb+12));
- olympic_priv->trb=ntohs(readw(init_srb+16));
+ olympic_priv->asb = swab16(readw(init_srb+8));
+ olympic_priv->srb = swab16(readw(init_srb+10));
+ olympic_priv->arb = swab16(readw(init_srb+12));
+ olympic_priv->trb = swab16(readw(init_srb+16));
olympic_priv->olympic_receive_options = 0x01 ;
olympic_priv->olympic_copy_all_options = 0 ;
@@ -513,8 +532,8 @@
skb->dev = dev;
- olympic_priv->olympic_rx_ring[i].buffer=virt_to_bus(skb->data);
- olympic_priv->olympic_rx_ring[i].res_length = olympic_priv->pkt_buf_sz ;
+ olympic_priv->olympic_rx_ring[i].buffer = cpu_to_le32(virt_to_bus(skb->data));
+ olympic_priv->olympic_rx_ring[i].res_length = cpu_to_le32(olympic_priv->pkt_buf_sz);
olympic_priv->rx_ring_skb[i]=skb;
}
@@ -524,17 +543,17 @@
return -EIO;
}
- writel(virt_to_bus(&olympic_priv->olympic_rx_ring[0]),olympic_mmio+RXDESCQ);
- writel(virt_to_bus(&olympic_priv->olympic_rx_ring[0]),olympic_mmio+RXCDA);
- writew(i,olympic_mmio+RXDESCQCNT);
+ writel(virt_to_bus(&olympic_priv->olympic_rx_ring[0]), olympic_mmio+RXDESCQ);
+ writel(virt_to_bus(&olympic_priv->olympic_rx_ring[0]), olympic_mmio+RXCDA);
+ writew(i, olympic_mmio+RXDESCQCNT);
- writel(virt_to_bus(&olympic_priv->olympic_rx_status_ring[0]),olympic_mmio+RXSTATQ);
- writel(virt_to_bus(&olympic_priv->olympic_rx_status_ring[0]),olympic_mmio+RXCSA);
+ writel(virt_to_bus(&olympic_priv->olympic_rx_status_ring[0]), olympic_mmio+RXSTATQ);
+ writel(virt_to_bus(&olympic_priv->olympic_rx_status_ring[0]), olympic_mmio+RXCSA);
- olympic_priv->rx_ring_last_received=OLYMPIC_RX_RING_SIZE-1; /* last processed rx status */
- olympic_priv->rx_status_last_received = OLYMPIC_RX_RING_SIZE-1;
+ olympic_priv->rx_ring_last_received = OLYMPIC_RX_RING_SIZE - 1; /* last processed rx status */
+ olympic_priv->rx_status_last_received = OLYMPIC_RX_RING_SIZE - 1;
- writew(i,olympic_mmio+RXSTATQCNT);
+ writew(i, olympic_mmio+RXSTATQCNT);
#if OLYMPIC_DEBUG
printk("# of rx buffers: %d, RXENQ: %x\n",i, readw(olympic_mmio+RXENQ));
@@ -563,9 +582,9 @@
olympic_priv->olympic_tx_ring[i].buffer=0xdeadbeef;
olympic_priv->free_tx_ring_entries=OLYMPIC_TX_RING_SIZE;
- writel(virt_to_bus(&olympic_priv->olympic_tx_ring[0]),olympic_mmio+TXDESCQ_1);
- writel(virt_to_bus(&olympic_priv->olympic_tx_ring[0]),olympic_mmio+TXCDA_1);
- writew(OLYMPIC_TX_RING_SIZE,olympic_mmio+TXDESCQCNT_1);
+ writel(virt_to_bus(&olympic_priv->olympic_tx_ring[0]), olympic_mmio+TXDESCQ_1);
+ writel(virt_to_bus(&olympic_priv->olympic_tx_ring[0]), olympic_mmio+TXCDA_1);
+ writew(OLYMPIC_TX_RING_SIZE, olympic_mmio+TXDESCQCNT_1);
writel(virt_to_bus(&olympic_priv->olympic_tx_status_ring[0]),olympic_mmio+TXSTATQ_1);
writel(virt_to_bus(&olympic_priv->olympic_tx_status_ring[0]),olympic_mmio+TXCSA_1);
@@ -642,34 +661,35 @@
rx_status=&(olympic_priv->olympic_rx_status_ring[(olympic_priv->rx_status_last_received + 1) & (OLYMPIC_RX_RING_SIZE - 1)]) ;
while (rx_status->status_buffercnt) {
+ __u32 l_status_buffercnt;
olympic_priv->rx_status_last_received++ ;
olympic_priv->rx_status_last_received &= (OLYMPIC_RX_RING_SIZE -1);
#if OLYMPIC_DEBUG
printk(" stat_ring addr: %x \n", &(olympic_priv->olympic_rx_status_ring[olympic_priv->rx_status_last_received]) );
- printk("rx status: %x rx len: %x \n",rx_status->status_buffercnt,rx_status->fragmentcnt_framelen);
+ printk("rx status: %x rx len: %x \n", le32_to_cpu(rx_status->status_buffercnt), le32_to_cpu(rx_status->fragmentcnt_framelen));
#endif
- length=rx_status->fragmentcnt_framelen & 0xffff;
- buffer_cnt = rx_status->status_buffercnt & 0xffff ;
+ length = le32_to_cpu(rx_status->fragmentcnt_framelen) & 0xffff;
+ buffer_cnt = le32_to_cpu(rx_status->status_buffercnt) & 0xffff;
i = buffer_cnt ; /* Need buffer_cnt later for rxenq update */
- frag_len = rx_status->fragmentcnt_framelen >> 16 ;
+ frag_len = le32_to_cpu(rx_status->fragmentcnt_framelen) >> 16;
#if OLYMPIC_DEBUG
- printk("length: %x, frag_len: %x, buffer_cnt: %x\n",length,frag_len,buffer_cnt);
+ printk("length: %x, frag_len: %x, buffer_cnt: %x\n", length, frag_len, buffer_cnt);
#endif
-
- if(rx_status->status_buffercnt & 0xC0000000) {
- if (rx_status->status_buffercnt & 0x3B000000) {
+ l_status_buffercnt = le32_to_cpu(rx_status->status_buffercnt);
+ if(l_status_buffercnt & 0xC0000000) {
+ if (l_status_buffercnt & 0x3B000000) {
if (olympic_priv->olympic_message_level) {
- if (rx_status->status_buffercnt & (1<<29)) /* Rx Frame Truncated */
+ if (l_status_buffercnt & (1<<29)) /* Rx Frame Truncated */
printk(KERN_WARNING "%s: Rx Frame Truncated \n",dev->name);
- if (rx_status->status_buffercnt & (1<<28)) /*Rx receive overrun */
+ if (l_status_buffercnt & (1<<28)) /*Rx receive overrun */
printk(KERN_WARNING "%s: Rx Frame Receive overrun \n",dev->name);
- if (rx_status->status_buffercnt & (1<<27)) /* No receive buffers */
+ if (l_status_buffercnt & (1<<27)) /* No receive buffers */
printk(KERN_WARNING "%s: No receive buffers \n",dev->name);
- if (rx_status->status_buffercnt & (1<<25)) /* Receive frame error detect */
+ if (l_status_buffercnt & (1<<25)) /* Receive frame error detect */
printk(KERN_WARNING "%s: Receive frame error detect \n",dev->name);
- if (rx_status->status_buffercnt & (1<<24)) /* Received Error Detect */
+ if (l_status_buffercnt & (1<<24)) /* Received Error Detect */
printk(KERN_WARNING "%s: Received Error Detect \n",dev->name);
}
olympic_priv->rx_ring_last_received += i ;
@@ -705,8 +725,8 @@
skb2=olympic_priv->rx_ring_skb[rx_ring_last_received] ;
skb_put(skb2,length);
skb2->protocol = tr_type_trans(skb2,dev);
- olympic_priv->olympic_rx_ring[rx_ring_last_received].buffer=virt_to_bus(skb->data);
- olympic_priv->olympic_rx_ring[rx_ring_last_received].res_length = olympic_priv->pkt_buf_sz ;
+ olympic_priv->olympic_rx_ring[rx_ring_last_received].buffer = cpu_to_le32(virt_to_bus(skb->data));
+ olympic_priv->olympic_rx_ring[rx_ring_last_received].res_length = cpu_to_le32(olympic_priv->pkt_buf_sz);
olympic_priv->rx_ring_skb[rx_ring_last_received] = skb ;
netif_rx(skb2) ;
} else {
@@ -715,8 +735,8 @@
olympic_priv->rx_ring_last_received &= (OLYMPIC_RX_RING_SIZE -1);
rx_ring_last_received = olympic_priv->rx_ring_last_received ;
rx_desc = &(olympic_priv->olympic_rx_ring[rx_ring_last_received]);
- cpy_length = (i == 1 ? frag_len : rx_desc->res_length);
- memcpy(skb_put(skb, cpy_length), bus_to_virt(rx_desc->buffer), cpy_length) ;
+ cpy_length = (i == 1 ? frag_len : le32_to_cpu(rx_desc->res_length));
+ memcpy(skb_put(skb, cpy_length), bus_to_virt(le32_to_cpu(rx_desc->buffer)), cpy_length) ;
} while (--i) ;
skb->protocol = tr_type_trans(skb,dev);
@@ -852,8 +872,8 @@
spin_lock_irqsave(&olympic_priv->olympic_lock, flags) ;
if(olympic_priv->free_tx_ring_entries) {
- olympic_priv->olympic_tx_ring[olympic_priv->tx_ring_free].buffer=virt_to_bus(skb->data);
- olympic_priv->olympic_tx_ring[olympic_priv->tx_ring_free].status_length=skb->len | (0x80000000);
+ olympic_priv->olympic_tx_ring[olympic_priv->tx_ring_free].buffer = cpu_to_le32(virt_to_bus(skb->data));
+ olympic_priv->olympic_tx_ring[olympic_priv->tx_ring_free].status_length = cpu_to_le32(skb->len | (0x80000000));
olympic_priv->tx_ring_skb[olympic_priv->tx_ring_free]=skb;
olympic_priv->free_tx_ring_entries--;
@@ -1240,9 +1260,9 @@
if (readb(arb_block+0) == ARB_RECEIVE_DATA) { /* Receive.data, MAC frames */
header_len = readb(arb_block+8) ; /* 802.5 Token-Ring Header Length */
- frame_len = ntohs(readw(arb_block + 10)) ;
+ frame_len = swab16(readw(arb_block + 10)) ;
- buff_off = ntohs(readw(arb_block + 6)) ;
+ buff_off = swab16(readw(arb_block + 6)) ;
buf_ptr = olympic_priv->olympic_lap + buff_off ;
@@ -1264,7 +1284,7 @@
do {
frame_data = buf_ptr+offsetof(struct mac_receive_buffer,frame_data) ;
- buffer_len = ntohs(readw(buf_ptr+offsetof(struct mac_receive_buffer,buffer_length)));
+ buffer_len = swab16(readw(buf_ptr+offsetof(struct mac_receive_buffer,buffer_length)));
memcpy_fromio(skb_put(mac_frame, buffer_len), frame_data , buffer_len ) ;
next_ptr=readw(buf_ptr+offsetof(struct mac_receive_buffer,next));
@@ -1301,12 +1321,12 @@
writel(LISR_ASB_REPLY | LISR_ASB_FREE_REQ,olympic_priv->olympic_mmio+LISR_SUM);
- olympic_priv->asb_queued = 2 ;
+ olympic_priv->asb_queued = 2;
- return ;
+ return;
} else if (readb(arb_block) == ARB_LAN_CHANGE_STATUS) { /* Lan.change.status */
- lan_status = ntohs(readw(arb_block+6)) ;
+ lan_status = swab16(readw(arb_block+6)) ;
fdx_prot_error = readb(arb_block+8) ;
/* Issue ARB Free */
@@ -1572,9 +1592,9 @@
readb(opt+offsetof(struct olympic_parameters_table, poll_addr)+3),
readb(opt+offsetof(struct olympic_parameters_table, poll_addr)+4),
readb(opt+offsetof(struct olympic_parameters_table, poll_addr)+5),
- ntohs(readw(opt+offsetof(struct olympic_parameters_table, acc_priority))),
- ntohs(readw(opt+offsetof(struct olympic_parameters_table, auth_source_class))),
- ntohs(readw(opt+offsetof(struct olympic_parameters_table, att_code))));
+ swab16(readw(opt+offsetof(struct olympic_parameters_table, acc_priority))),
+ swab16(readw(opt+offsetof(struct olympic_parameters_table, auth_source_class))),
+ swab16(readw(opt+offsetof(struct olympic_parameters_table, att_code))));
size += sprintf(buffer+size, "%6s: Source Address : Bcn T : Maj. V : Lan St : Lcl Rg : Mon Err : Frame Correl : \n",
dev->name) ;
@@ -1587,20 +1607,20 @@
readb(opt+offsetof(struct olympic_parameters_table, source_addr)+3),
readb(opt+offsetof(struct olympic_parameters_table, source_addr)+4),
readb(opt+offsetof(struct olympic_parameters_table, source_addr)+5),
- ntohs(readw(opt+offsetof(struct olympic_parameters_table, beacon_type))),
- ntohs(readw(opt+offsetof(struct olympic_parameters_table, major_vector))),
- ntohs(readw(opt+offsetof(struct olympic_parameters_table, lan_status))),
- ntohs(readw(opt+offsetof(struct olympic_parameters_table, local_ring))),
- ntohs(readw(opt+offsetof(struct olympic_parameters_table, mon_error))),
- ntohs(readw(opt+offsetof(struct olympic_parameters_table, frame_correl))));
+ swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_type))),
+ swab16(readw(opt+offsetof(struct olympic_parameters_table, major_vector))),
+ swab16(readw(opt+offsetof(struct olympic_parameters_table, lan_status))),
+ swab16(readw(opt+offsetof(struct olympic_parameters_table, local_ring))),
+ swab16(readw(opt+offsetof(struct olympic_parameters_table, mon_error))),
+ swab16(readw(opt+offsetof(struct olympic_parameters_table, frame_correl))));
size += sprintf(buffer+size, "%6s: Beacon Details : Tx : Rx : NAUN Node Address : NAUN Node Phys : \n",
dev->name) ;
size += sprintf(buffer+size, "%6s: : %02x : %02x : %02x:%02x:%02x:%02x:%02x:%02x : %02x:%02x:%02x:%02x : \n",
dev->name,
- ntohs(readw(opt+offsetof(struct olympic_parameters_table, beacon_transmit))),
- ntohs(readw(opt+offsetof(struct olympic_parameters_table, beacon_receive))),
+ swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_transmit))),
+ swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_receive))),
readb(opt+offsetof(struct olympic_parameters_table, beacon_naun)),
readb(opt+offsetof(struct olympic_parameters_table, beacon_naun)+1),
readb(opt+offsetof(struct olympic_parameters_table, beacon_naun)+2),
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)