aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/via-velocity.c70
-rw-r--r--drivers/net/via-velocity.h224
2 files changed, 128 insertions, 166 deletions
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index 35cd65d6b9ed..8c9fb824cbd4 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -8,7 +8,6 @@
8 * for 64bit hardware platforms. 8 * for 64bit hardware platforms.
9 * 9 *
10 * TODO 10 * TODO
11 * Big-endian support
12 * rx_copybreak/alignment 11 * rx_copybreak/alignment
13 * Scatter gather 12 * Scatter gather
14 * More testing 13 * More testing
@@ -681,7 +680,7 @@ static void velocity_rx_reset(struct velocity_info *vptr)
681 * Init state, all RD entries belong to the NIC 680 * Init state, all RD entries belong to the NIC
682 */ 681 */
683 for (i = 0; i < vptr->options.numrx; ++i) 682 for (i = 0; i < vptr->options.numrx; ++i)
684 vptr->rd_ring[i].rdesc0.owner = OWNED_BY_NIC; 683 vptr->rd_ring[i].rdesc0.len |= OWNED_BY_NIC;
685 684
686 writew(vptr->options.numrx, &regs->RBRDU); 685 writew(vptr->options.numrx, &regs->RBRDU);
687 writel(vptr->rd_pool_dma, &regs->RDBaseLo); 686 writel(vptr->rd_pool_dma, &regs->RDBaseLo);
@@ -777,7 +776,7 @@ static void velocity_init_registers(struct velocity_info *vptr,
777 776
778 vptr->int_mask = INT_MASK_DEF; 777 vptr->int_mask = INT_MASK_DEF;
779 778
780 writel(cpu_to_le32(vptr->rd_pool_dma), &regs->RDBaseLo); 779 writel(vptr->rd_pool_dma, &regs->RDBaseLo);
781 writew(vptr->options.numrx - 1, &regs->RDCSize); 780 writew(vptr->options.numrx - 1, &regs->RDCSize);
782 mac_rx_queue_run(regs); 781 mac_rx_queue_run(regs);
783 mac_rx_queue_wake(regs); 782 mac_rx_queue_wake(regs);
@@ -785,7 +784,7 @@ static void velocity_init_registers(struct velocity_info *vptr,
785 writew(vptr->options.numtx - 1, &regs->TDCSize); 784 writew(vptr->options.numtx - 1, &regs->TDCSize);
786 785
787 for (i = 0; i < vptr->num_txq; i++) { 786 for (i = 0; i < vptr->num_txq; i++) {
788 writel(cpu_to_le32(vptr->td_pool_dma[i]), &(regs->TDBaseLo[i])); 787 writel(vptr->td_pool_dma[i], &regs->TDBaseLo[i]);
789 mac_tx_queue_run(regs, i); 788 mac_tx_queue_run(regs, i);
790 } 789 }
791 790
@@ -1195,7 +1194,7 @@ static inline void velocity_give_many_rx_descs(struct velocity_info *vptr)
1195 dirty = vptr->rd_dirty - unusable; 1194 dirty = vptr->rd_dirty - unusable;
1196 for (avail = vptr->rd_filled & 0xfffc; avail; avail--) { 1195 for (avail = vptr->rd_filled & 0xfffc; avail; avail--) {
1197 dirty = (dirty > 0) ? dirty - 1 : vptr->options.numrx - 1; 1196 dirty = (dirty > 0) ? dirty - 1 : vptr->options.numrx - 1;
1198 vptr->rd_ring[dirty].rdesc0.owner = OWNED_BY_NIC; 1197 vptr->rd_ring[dirty].rdesc0.len |= OWNED_BY_NIC;
1199 } 1198 }
1200 1199
1201 writew(vptr->rd_filled & 0xfffc, &regs->RBRDU); 1200 writew(vptr->rd_filled & 0xfffc, &regs->RBRDU);
@@ -1210,7 +1209,7 @@ static int velocity_rx_refill(struct velocity_info *vptr)
1210 struct rx_desc *rd = vptr->rd_ring + dirty; 1209 struct rx_desc *rd = vptr->rd_ring + dirty;
1211 1210
1212 /* Fine for an all zero Rx desc at init time as well */ 1211 /* Fine for an all zero Rx desc at init time as well */
1213 if (rd->rdesc0.owner == OWNED_BY_NIC) 1212 if (rd->rdesc0.len & OWNED_BY_NIC)
1214 break; 1213 break;
1215 1214
1216 if (!vptr->rd_info[dirty].skb) { 1215 if (!vptr->rd_info[dirty].skb) {
@@ -1413,7 +1412,7 @@ static int velocity_rx_srv(struct velocity_info *vptr, int status)
1413 if (!vptr->rd_info[rd_curr].skb) 1412 if (!vptr->rd_info[rd_curr].skb)
1414 break; 1413 break;
1415 1414
1416 if (rd->rdesc0.owner == OWNED_BY_NIC) 1415 if (rd->rdesc0.len & OWNED_BY_NIC)
1417 break; 1416 break;
1418 1417
1419 rmb(); 1418 rmb();
@@ -1421,7 +1420,7 @@ static int velocity_rx_srv(struct velocity_info *vptr, int status)
1421 /* 1420 /*
1422 * Don't drop CE or RL error frame although RXOK is off 1421 * Don't drop CE or RL error frame although RXOK is off
1423 */ 1422 */
1424 if ((rd->rdesc0.RSR & RSR_RXOK) || (!(rd->rdesc0.RSR & RSR_RXOK) && (rd->rdesc0.RSR & (RSR_CE | RSR_RL)))) { 1423 if (rd->rdesc0.RSR & (RSR_RXOK | RSR_CE | RSR_RL)) {
1425 if (velocity_receive_frame(vptr, rd_curr) < 0) 1424 if (velocity_receive_frame(vptr, rd_curr) < 0)
1426 stats->rx_dropped++; 1425 stats->rx_dropped++;
1427 } else { 1426 } else {
@@ -1433,7 +1432,7 @@ static int velocity_rx_srv(struct velocity_info *vptr, int status)
1433 stats->rx_dropped++; 1432 stats->rx_dropped++;
1434 } 1433 }
1435 1434
1436 rd->inten = 1; 1435 rd->size |= RX_INTEN;
1437 1436
1438 vptr->dev->last_rx = jiffies; 1437 vptr->dev->last_rx = jiffies;
1439 1438
@@ -1554,7 +1553,7 @@ static int velocity_receive_frame(struct velocity_info *vptr, int idx)
1554 struct net_device_stats *stats = &vptr->stats; 1553 struct net_device_stats *stats = &vptr->stats;
1555 struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]); 1554 struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]);
1556 struct rx_desc *rd = &(vptr->rd_ring[idx]); 1555 struct rx_desc *rd = &(vptr->rd_ring[idx]);
1557 int pkt_len = rd->rdesc0.len; 1556 int pkt_len = le16_to_cpu(rd->rdesc0.len) & 0x3fff;
1558 struct sk_buff *skb; 1557 struct sk_buff *skb;
1559 1558
1560 if (rd->rdesc0.RSR & (RSR_STP | RSR_EDP)) { 1559 if (rd->rdesc0.RSR & (RSR_STP | RSR_EDP)) {
@@ -1637,8 +1636,7 @@ static int velocity_alloc_rx_buf(struct velocity_info *vptr, int idx)
1637 */ 1636 */
1638 1637
1639 *((u32 *) & (rd->rdesc0)) = 0; 1638 *((u32 *) & (rd->rdesc0)) = 0;
1640 rd->len = cpu_to_le32(vptr->rx_buf_sz); 1639 rd->size = cpu_to_le16(vptr->rx_buf_sz) | RX_INTEN;
1641 rd->inten = 1;
1642 rd->pa_low = cpu_to_le32(rd_info->skb_dma); 1640 rd->pa_low = cpu_to_le32(rd_info->skb_dma);
1643 rd->pa_high = 0; 1641 rd->pa_high = 0;
1644 return 0; 1642 return 0;
@@ -1674,7 +1672,7 @@ static int velocity_tx_srv(struct velocity_info *vptr, u32 status)
1674 td = &(vptr->td_rings[qnum][idx]); 1672 td = &(vptr->td_rings[qnum][idx]);
1675 tdinfo = &(vptr->td_infos[qnum][idx]); 1673 tdinfo = &(vptr->td_infos[qnum][idx]);
1676 1674
1677 if (td->tdesc0.owner == OWNED_BY_NIC) 1675 if (td->tdesc0.len & OWNED_BY_NIC)
1678 break; 1676 break;
1679 1677
1680 if ((works++ > 15)) 1678 if ((works++ > 15))
@@ -1874,7 +1872,7 @@ static void velocity_free_tx_buf(struct velocity_info *vptr, struct velocity_td_
1874 1872
1875 for (i = 0; i < tdinfo->nskb_dma; i++) { 1873 for (i = 0; i < tdinfo->nskb_dma; i++) {
1876#ifdef VELOCITY_ZERO_COPY_SUPPORT 1874#ifdef VELOCITY_ZERO_COPY_SUPPORT
1877 pci_unmap_single(vptr->pdev, tdinfo->skb_dma[i], td->tdesc1.len, PCI_DMA_TODEVICE); 1875 pci_unmap_single(vptr->pdev, tdinfo->skb_dma[i], le16_to_cpu(td->tdesc1.len), PCI_DMA_TODEVICE);
1878#else 1876#else
1879 pci_unmap_single(vptr->pdev, tdinfo->skb_dma[i], skb->len, PCI_DMA_TODEVICE); 1877 pci_unmap_single(vptr->pdev, tdinfo->skb_dma[i], skb->len, PCI_DMA_TODEVICE);
1880#endif 1878#endif
@@ -2067,8 +2065,8 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)
2067 struct velocity_td_info *tdinfo; 2065 struct velocity_td_info *tdinfo;
2068 unsigned long flags; 2066 unsigned long flags;
2069 int index; 2067 int index;
2070
2071 int pktlen = skb->len; 2068 int pktlen = skb->len;
2069 __le16 len = cpu_to_le16(pktlen);
2072 2070
2073#ifdef VELOCITY_ZERO_COPY_SUPPORT 2071#ifdef VELOCITY_ZERO_COPY_SUPPORT
2074 if (skb_shinfo(skb)->nr_frags > 6 && __skb_linearize(skb)) { 2072 if (skb_shinfo(skb)->nr_frags > 6 && __skb_linearize(skb)) {
@@ -2083,9 +2081,8 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)
2083 td_ptr = &(vptr->td_rings[qnum][index]); 2081 td_ptr = &(vptr->td_rings[qnum][index]);
2084 tdinfo = &(vptr->td_infos[qnum][index]); 2082 tdinfo = &(vptr->td_infos[qnum][index]);
2085 2083
2086 td_ptr->tdesc1.TCPLS = TCPLS_NORMAL;
2087 td_ptr->tdesc1.TCR = TCR0_TIC; 2084 td_ptr->tdesc1.TCR = TCR0_TIC;
2088 td_ptr->td_buf[0].queue = 0; 2085 td_ptr->td_buf[0].size &= ~TD_QUEUE;
2089 2086
2090 /* 2087 /*
2091 * Pad short frames. 2088 * Pad short frames.
@@ -2093,16 +2090,16 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)
2093 if (pktlen < ETH_ZLEN) { 2090 if (pktlen < ETH_ZLEN) {
2094 /* Cannot occur until ZC support */ 2091 /* Cannot occur until ZC support */
2095 pktlen = ETH_ZLEN; 2092 pktlen = ETH_ZLEN;
2093 len = cpu_to_le16(ETH_ZLEN);
2096 skb_copy_from_linear_data(skb, tdinfo->buf, skb->len); 2094 skb_copy_from_linear_data(skb, tdinfo->buf, skb->len);
2097 memset(tdinfo->buf + skb->len, 0, ETH_ZLEN - skb->len); 2095 memset(tdinfo->buf + skb->len, 0, ETH_ZLEN - skb->len);
2098 tdinfo->skb = skb; 2096 tdinfo->skb = skb;
2099 tdinfo->skb_dma[0] = tdinfo->buf_dma; 2097 tdinfo->skb_dma[0] = tdinfo->buf_dma;
2100 td_ptr->tdesc0.pktsize = pktlen; 2098 td_ptr->tdesc0.len = len;
2101 td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]); 2099 td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]);
2102 td_ptr->td_buf[0].pa_high = 0; 2100 td_ptr->td_buf[0].pa_high = 0;
2103 td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize; 2101 td_ptr->td_buf[0].size = len; /* queue is 0 anyway */
2104 tdinfo->nskb_dma = 1; 2102 tdinfo->nskb_dma = 1;
2105 td_ptr->tdesc1.CMDZ = 2;
2106 } else 2103 } else
2107#ifdef VELOCITY_ZERO_COPY_SUPPORT 2104#ifdef VELOCITY_ZERO_COPY_SUPPORT
2108 if (skb_shinfo(skb)->nr_frags > 0) { 2105 if (skb_shinfo(skb)->nr_frags > 0) {
@@ -2111,36 +2108,35 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)
2111 if (nfrags > 6) { 2108 if (nfrags > 6) {
2112 skb_copy_from_linear_data(skb, tdinfo->buf, skb->len); 2109 skb_copy_from_linear_data(skb, tdinfo->buf, skb->len);
2113 tdinfo->skb_dma[0] = tdinfo->buf_dma; 2110 tdinfo->skb_dma[0] = tdinfo->buf_dma;
2114 td_ptr->tdesc0.pktsize = 2111 td_ptr->tdesc0.len = len;
2115 td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]); 2112 td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]);
2116 td_ptr->td_buf[0].pa_high = 0; 2113 td_ptr->td_buf[0].pa_high = 0;
2117 td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize; 2114 td_ptr->td_buf[0].size = len; /* queue is 0 anyway */
2118 tdinfo->nskb_dma = 1; 2115 tdinfo->nskb_dma = 1;
2119 td_ptr->tdesc1.CMDZ = 2;
2120 } else { 2116 } else {
2121 int i = 0; 2117 int i = 0;
2122 tdinfo->nskb_dma = 0; 2118 tdinfo->nskb_dma = 0;
2123 tdinfo->skb_dma[i] = pci_map_single(vptr->pdev, skb->data, skb->len - skb->data_len, PCI_DMA_TODEVICE); 2119 tdinfo->skb_dma[i] = pci_map_single(vptr->pdev, skb->data,
2120 skb_headlen(skb), PCI_DMA_TODEVICE);
2124 2121
2125 td_ptr->tdesc0.pktsize = pktlen; 2122 td_ptr->tdesc0.len = len;
2126 2123
2127 /* FIXME: support 48bit DMA later */ 2124 /* FIXME: support 48bit DMA later */
2128 td_ptr->td_buf[i].pa_low = cpu_to_le32(tdinfo->skb_dma); 2125 td_ptr->td_buf[i].pa_low = cpu_to_le32(tdinfo->skb_dma);
2129 td_ptr->td_buf[i].pa_high = 0; 2126 td_ptr->td_buf[i].pa_high = 0;
2130 td_ptr->td_buf[i].bufsize = skb->len->skb->data_len; 2127 td_ptr->td_buf[i].size = cpu_to_le16(skb_headlen(skb));
2131 2128
2132 for (i = 0; i < nfrags; i++) { 2129 for (i = 0; i < nfrags; i++) {
2133 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; 2130 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
2134 void *addr = ((void *) page_address(frag->page + frag->page_offset)); 2131 void *addr = (void *)page_address(frag->page) + frag->page_offset;
2135 2132
2136 tdinfo->skb_dma[i + 1] = pci_map_single(vptr->pdev, addr, frag->size, PCI_DMA_TODEVICE); 2133 tdinfo->skb_dma[i + 1] = pci_map_single(vptr->pdev, addr, frag->size, PCI_DMA_TODEVICE);
2137 2134
2138 td_ptr->td_buf[i + 1].pa_low = cpu_to_le32(tdinfo->skb_dma[i + 1]); 2135 td_ptr->td_buf[i + 1].pa_low = cpu_to_le32(tdinfo->skb_dma[i + 1]);
2139 td_ptr->td_buf[i + 1].pa_high = 0; 2136 td_ptr->td_buf[i + 1].pa_high = 0;
2140 td_ptr->td_buf[i + 1].bufsize = frag->size; 2137 td_ptr->td_buf[i + 1].size = cpu_to_le16(frag->size);
2141 } 2138 }
2142 tdinfo->nskb_dma = i - 1; 2139 tdinfo->nskb_dma = i - 1;
2143 td_ptr->tdesc1.CMDZ = i;
2144 } 2140 }
2145 2141
2146 } else 2142 } else
@@ -2152,18 +2148,16 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)
2152 */ 2148 */
2153 tdinfo->skb = skb; 2149 tdinfo->skb = skb;
2154 tdinfo->skb_dma[0] = pci_map_single(vptr->pdev, skb->data, pktlen, PCI_DMA_TODEVICE); 2150 tdinfo->skb_dma[0] = pci_map_single(vptr->pdev, skb->data, pktlen, PCI_DMA_TODEVICE);
2155 td_ptr->tdesc0.pktsize = pktlen; 2151 td_ptr->tdesc0.len = len;
2156 td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]); 2152 td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]);
2157 td_ptr->td_buf[0].pa_high = 0; 2153 td_ptr->td_buf[0].pa_high = 0;
2158 td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize; 2154 td_ptr->td_buf[0].size = len;
2159 tdinfo->nskb_dma = 1; 2155 tdinfo->nskb_dma = 1;
2160 td_ptr->tdesc1.CMDZ = 2;
2161 } 2156 }
2157 td_ptr->tdesc1.cmd = TCPLS_NORMAL + (tdinfo->nskb_dma + 1) * 16;
2162 2158
2163 if (vptr->vlgrp && vlan_tx_tag_present(skb)) { 2159 if (vptr->vlgrp && vlan_tx_tag_present(skb)) {
2164 td_ptr->tdesc1.pqinf.VID = vlan_tx_tag_get(skb); 2160 td_ptr->tdesc1.vlan = cpu_to_le16(vlan_tx_tag_get(skb));
2165 td_ptr->tdesc1.pqinf.priority = 0;
2166 td_ptr->tdesc1.pqinf.CFI = 0;
2167 td_ptr->tdesc1.TCR |= TCR0_VETAG; 2161 td_ptr->tdesc1.TCR |= TCR0_VETAG;
2168 } 2162 }
2169 2163
@@ -2185,7 +2179,7 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)
2185 2179
2186 if (prev < 0) 2180 if (prev < 0)
2187 prev = vptr->options.numtx - 1; 2181 prev = vptr->options.numtx - 1;
2188 td_ptr->tdesc0.owner = OWNED_BY_NIC; 2182 td_ptr->tdesc0.len |= OWNED_BY_NIC;
2189 vptr->td_used[qnum]++; 2183 vptr->td_used[qnum]++;
2190 vptr->td_curr[qnum] = (index + 1) % vptr->options.numtx; 2184 vptr->td_curr[qnum] = (index + 1) % vptr->options.numtx;
2191 2185
@@ -2193,7 +2187,7 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)
2193 netif_stop_queue(dev); 2187 netif_stop_queue(dev);
2194 2188
2195 td_ptr = &(vptr->td_rings[qnum][prev]); 2189 td_ptr = &(vptr->td_rings[qnum][prev]);
2196 td_ptr->td_buf[0].queue = 1; 2190 td_ptr->td_buf[0].size |= TD_QUEUE;
2197 mac_tx_queue_wake(vptr->mac_regs, qnum); 2191 mac_tx_queue_wake(vptr->mac_regs, qnum);
2198 } 2192 }
2199 dev->trans_start = jiffies; 2193 dev->trans_start = jiffies;
@@ -3410,7 +3404,7 @@ static int velocity_suspend(struct pci_dev *pdev, pm_message_t state)
3410 velocity_save_context(vptr, &vptr->context); 3404 velocity_save_context(vptr, &vptr->context);
3411 velocity_shutdown(vptr); 3405 velocity_shutdown(vptr);
3412 velocity_set_wol(vptr); 3406 velocity_set_wol(vptr);
3413 pci_enable_wake(pdev, 3, 1); 3407 pci_enable_wake(pdev, PCI_D3hot, 1);
3414 pci_set_power_state(pdev, PCI_D3hot); 3408 pci_set_power_state(pdev, PCI_D3hot);
3415 } else { 3409 } else {
3416 velocity_save_context(vptr, &vptr->context); 3410 velocity_save_context(vptr, &vptr->context);
diff --git a/drivers/net/via-velocity.h b/drivers/net/via-velocity.h
index aa9179623d90..7387be4f428d 100644
--- a/drivers/net/via-velocity.h
+++ b/drivers/net/via-velocity.h
@@ -70,40 +70,27 @@
70 * Bits in the RSR0 register 70 * Bits in the RSR0 register
71 */ 71 */
72 72
73#define RSR_DETAG 0x0080 73#define RSR_DETAG cpu_to_le16(0x0080)
74#define RSR_SNTAG 0x0040 74#define RSR_SNTAG cpu_to_le16(0x0040)
75#define RSR_RXER 0x0020 75#define RSR_RXER cpu_to_le16(0x0020)
76#define RSR_RL 0x0010 76#define RSR_RL cpu_to_le16(0x0010)
77#define RSR_CE 0x0008 77#define RSR_CE cpu_to_le16(0x0008)
78#define RSR_FAE 0x0004 78#define RSR_FAE cpu_to_le16(0x0004)
79#define RSR_CRC 0x0002 79#define RSR_CRC cpu_to_le16(0x0002)
80#define RSR_VIDM 0x0001 80#define RSR_VIDM cpu_to_le16(0x0001)
81 81
82/* 82/*
83 * Bits in the RSR1 register 83 * Bits in the RSR1 register
84 */ 84 */
85 85
86#define RSR_RXOK 0x8000 // rx OK 86#define RSR_RXOK cpu_to_le16(0x8000) // rx OK
87#define RSR_PFT 0x4000 // Perfect filtering address match 87#define RSR_PFT cpu_to_le16(0x4000) // Perfect filtering address match
88#define RSR_MAR 0x2000 // MAC accept multicast address packet 88#define RSR_MAR cpu_to_le16(0x2000) // MAC accept multicast address packet
89#define RSR_BAR 0x1000 // MAC accept broadcast address packet 89#define RSR_BAR cpu_to_le16(0x1000) // MAC accept broadcast address packet
90#define RSR_PHY 0x0800 // MAC accept physical address packet 90#define RSR_PHY cpu_to_le16(0x0800) // MAC accept physical address packet
91#define RSR_VTAG 0x0400 // 802.1p/1q tagging packet indicator 91#define RSR_VTAG cpu_to_le16(0x0400) // 802.1p/1q tagging packet indicator
92#define RSR_STP 0x0200 // start of packet 92#define RSR_STP cpu_to_le16(0x0200) // start of packet
93#define RSR_EDP 0x0100 // end of packet 93#define RSR_EDP cpu_to_le16(0x0100) // end of packet
94
95/*
96 * Bits in the RSR1 register
97 */
98
99#define RSR1_RXOK 0x80 // rx OK
100#define RSR1_PFT 0x40 // Perfect filtering address match
101#define RSR1_MAR 0x20 // MAC accept multicast address packet
102#define RSR1_BAR 0x10 // MAC accept broadcast address packet
103#define RSR1_PHY 0x08 // MAC accept physical address packet
104#define RSR1_VTAG 0x04 // 802.1p/1q tagging packet indicator
105#define RSR1_STP 0x02 // start of packet
106#define RSR1_EDP 0x01 // end of packet
107 94
108/* 95/*
109 * Bits in the CSM register 96 * Bits in the CSM register
@@ -120,33 +107,21 @@
120 * Bits in the TSR0 register 107 * Bits in the TSR0 register
121 */ 108 */
122 109
123#define TSR0_ABT 0x0080 // Tx abort because of excessive collision 110#define TSR0_ABT cpu_to_le16(0x0080) // Tx abort because of excessive collision
124#define TSR0_OWT 0x0040 // Jumbo frame Tx abort 111#define TSR0_OWT cpu_to_le16(0x0040) // Jumbo frame Tx abort
125#define TSR0_OWC 0x0020 // Out of window collision 112#define TSR0_OWC cpu_to_le16(0x0020) // Out of window collision
126#define TSR0_COLS 0x0010 // experience collision in this transmit event 113#define TSR0_COLS cpu_to_le16(0x0010) // experience collision in this transmit event
127#define TSR0_NCR3 0x0008 // collision retry counter[3] 114#define TSR0_NCR3 cpu_to_le16(0x0008) // collision retry counter[3]
128#define TSR0_NCR2 0x0004 // collision retry counter[2] 115#define TSR0_NCR2 cpu_to_le16(0x0004) // collision retry counter[2]
129#define TSR0_NCR1 0x0002 // collision retry counter[1] 116#define TSR0_NCR1 cpu_to_le16(0x0002) // collision retry counter[1]
130#define TSR0_NCR0 0x0001 // collision retry counter[0] 117#define TSR0_NCR0 cpu_to_le16(0x0001) // collision retry counter[0]
131#define TSR0_TERR 0x8000 // 118#define TSR0_TERR cpu_to_le16(0x8000) //
132#define TSR0_FDX 0x4000 // current transaction is serviced by full duplex mode 119#define TSR0_FDX cpu_to_le16(0x4000) // current transaction is serviced by full duplex mode
133#define TSR0_GMII 0x2000 // current transaction is serviced by GMII mode 120#define TSR0_GMII cpu_to_le16(0x2000) // current transaction is serviced by GMII mode
134#define TSR0_LNKFL 0x1000 // packet serviced during link down 121#define TSR0_LNKFL cpu_to_le16(0x1000) // packet serviced during link down
135#define TSR0_SHDN 0x0400 // shutdown case 122#define TSR0_SHDN cpu_to_le16(0x0400) // shutdown case
136#define TSR0_CRS 0x0200 // carrier sense lost 123#define TSR0_CRS cpu_to_le16(0x0200) // carrier sense lost
137#define TSR0_CDH 0x0100 // AQE test fail (CD heartbeat) 124#define TSR0_CDH cpu_to_le16(0x0100) // AQE test fail (CD heartbeat)
138
139/*
140 * Bits in the TSR1 register
141 */
142
143#define TSR1_TERR 0x80 //
144#define TSR1_FDX 0x40 // current transaction is serviced by full duplex mode
145#define TSR1_GMII 0x20 // current transaction is serviced by GMII mode
146#define TSR1_LNKFL 0x10 // packet serviced during link down
147#define TSR1_SHDN 0x04 // shutdown case
148#define TSR1_CRS 0x02 // carrier sense lost
149#define TSR1_CDH 0x01 // AQE test fail (CD heartbeat)
150 125
151// 126//
152// Bits in the TCR0 register 127// Bits in the TCR0 register
@@ -197,25 +172,26 @@
197 */ 172 */
198 173
199struct rdesc0 { 174struct rdesc0 {
200 u16 RSR; /* Receive status */ 175 __le16 RSR; /* Receive status */
201 u16 len:14; /* Received packet length */ 176 __le16 len; /* bits 0--13; bit 15 - owner */
202 u16 reserved:1;
203 u16 owner:1; /* Who owns this buffer ? */
204}; 177};
205 178
206struct rdesc1 { 179struct rdesc1 {
207 u16 PQTAG; 180 __le16 PQTAG;
208 u8 CSM; 181 u8 CSM;
209 u8 IPKT; 182 u8 IPKT;
210}; 183};
211 184
185enum {
186 RX_INTEN = __constant_cpu_to_le16(0x8000)
187};
188
212struct rx_desc { 189struct rx_desc {
213 struct rdesc0 rdesc0; 190 struct rdesc0 rdesc0;
214 struct rdesc1 rdesc1; 191 struct rdesc1 rdesc1;
215 u32 pa_low; /* Low 32 bit PCI address */ 192 __le32 pa_low; /* Low 32 bit PCI address */
216 u16 pa_high; /* Next 16 bit PCI address (48 total) */ 193 __le16 pa_high; /* Next 16 bit PCI address (48 total) */
217 u16 len:15; /* Frame size */ 194 __le16 size; /* bits 0--14 - frame size, bit 15 - enable int. */
218 u16 inten:1; /* Enable interrupt */
219} __attribute__ ((__packed__)); 195} __attribute__ ((__packed__));
220 196
221/* 197/*
@@ -223,32 +199,24 @@ struct rx_desc {
223 */ 199 */
224 200
225struct tdesc0 { 201struct tdesc0 {
226 u16 TSR; /* Transmit status register */ 202 __le16 TSR; /* Transmit status register */
227 u16 pktsize:14; /* Size of frame */ 203 __le16 len; /* bits 0--13 - size of frame, bit 15 - owner */
228 u16 reserved:1;
229 u16 owner:1; /* Who owns the buffer */
230}; 204};
231 205
232struct pqinf { /* Priority queue info */
233 u16 VID:12;
234 u16 CFI:1;
235 u16 priority:3;
236} __attribute__ ((__packed__));
237
238struct tdesc1 { 206struct tdesc1 {
239 struct pqinf pqinf; 207 __le16 vlan;
240 u8 TCR; 208 u8 TCR;
241 u8 TCPLS:2; 209 u8 cmd; /* bits 0--1 - TCPLS, bits 4--7 - CMDZ */
242 u8 reserved:2;
243 u8 CMDZ:4;
244} __attribute__ ((__packed__)); 210} __attribute__ ((__packed__));
245 211
212enum {
213 TD_QUEUE = __constant_cpu_to_le16(0x8000)
214};
215
246struct td_buf { 216struct td_buf {
247 u32 pa_low; 217 __le32 pa_low;
248 u16 pa_high; 218 __le16 pa_high;
249 u16 bufsize:14; 219 __le16 size; /* bits 0--13 - size, bit 15 - queue */
250 u16 reserved:1;
251 u16 queue:1;
252} __attribute__ ((__packed__)); 220} __attribute__ ((__packed__));
253 221
254struct tx_desc { 222struct tx_desc {
@@ -276,7 +244,7 @@ struct velocity_td_info {
276 244
277enum velocity_owner { 245enum velocity_owner {
278 OWNED_BY_HOST = 0, 246 OWNED_BY_HOST = 0,
279 OWNED_BY_NIC = 1 247 OWNED_BY_NIC = __constant_cpu_to_le16(0x8000)
280}; 248};
281 249
282 250
@@ -1012,45 +980,45 @@ struct mac_regs {
1012 volatile u8 RCR; 980 volatile u8 RCR;
1013 volatile u8 TCR; 981 volatile u8 TCR;
1014 982
1015 volatile u32 CR0Set; /* 0x08 */ 983 volatile __le32 CR0Set; /* 0x08 */
1016 volatile u32 CR0Clr; /* 0x0C */ 984 volatile __le32 CR0Clr; /* 0x0C */
1017 985
1018 volatile u8 MARCAM[8]; /* 0x10 */ 986 volatile u8 MARCAM[8]; /* 0x10 */
1019 987
1020 volatile u32 DecBaseHi; /* 0x18 */ 988 volatile __le32 DecBaseHi; /* 0x18 */
1021 volatile u16 DbfBaseHi; /* 0x1C */ 989 volatile __le16 DbfBaseHi; /* 0x1C */
1022 volatile u16 reserved_1E; 990 volatile __le16 reserved_1E;
1023 991
1024 volatile u16 ISRCTL; /* 0x20 */ 992 volatile __le16 ISRCTL; /* 0x20 */
1025 volatile u8 TXESR; 993 volatile u8 TXESR;
1026 volatile u8 RXESR; 994 volatile u8 RXESR;
1027 995
1028 volatile u32 ISR; /* 0x24 */ 996 volatile __le32 ISR; /* 0x24 */
1029 volatile u32 IMR; 997 volatile __le32 IMR;
1030 998
1031 volatile u32 TDStatusPort; /* 0x2C */ 999 volatile __le32 TDStatusPort; /* 0x2C */
1032 1000
1033 volatile u16 TDCSRSet; /* 0x30 */ 1001 volatile __le16 TDCSRSet; /* 0x30 */
1034 volatile u8 RDCSRSet; 1002 volatile u8 RDCSRSet;
1035 volatile u8 reserved_33; 1003 volatile u8 reserved_33;
1036 volatile u16 TDCSRClr; 1004 volatile __le16 TDCSRClr;
1037 volatile u8 RDCSRClr; 1005 volatile u8 RDCSRClr;
1038 volatile u8 reserved_37; 1006 volatile u8 reserved_37;
1039 1007
1040 volatile u32 RDBaseLo; /* 0x38 */ 1008 volatile __le32 RDBaseLo; /* 0x38 */
1041 volatile u16 RDIdx; /* 0x3C */ 1009 volatile __le16 RDIdx; /* 0x3C */
1042 volatile u16 reserved_3E; 1010 volatile __le16 reserved_3E;
1043 1011
1044 volatile u32 TDBaseLo[4]; /* 0x40 */ 1012 volatile __le32 TDBaseLo[4]; /* 0x40 */
1045 1013
1046 volatile u16 RDCSize; /* 0x50 */ 1014 volatile __le16 RDCSize; /* 0x50 */
1047 volatile u16 TDCSize; /* 0x52 */ 1015 volatile __le16 TDCSize; /* 0x52 */
1048 volatile u16 TDIdx[4]; /* 0x54 */ 1016 volatile __le16 TDIdx[4]; /* 0x54 */
1049 volatile u16 tx_pause_timer; /* 0x5C */ 1017 volatile __le16 tx_pause_timer; /* 0x5C */
1050 volatile u16 RBRDU; /* 0x5E */ 1018 volatile __le16 RBRDU; /* 0x5E */
1051 1019
1052 volatile u32 FIFOTest0; /* 0x60 */ 1020 volatile __le32 FIFOTest0; /* 0x60 */
1053 volatile u32 FIFOTest1; /* 0x64 */ 1021 volatile __le32 FIFOTest1; /* 0x64 */
1054 1022
1055 volatile u8 CAMADDR; /* 0x68 */ 1023 volatile u8 CAMADDR; /* 0x68 */
1056 volatile u8 CAMCR; /* 0x69 */ 1024 volatile u8 CAMCR; /* 0x69 */
@@ -1063,18 +1031,18 @@ struct mac_regs {
1063 volatile u8 PHYSR1; 1031 volatile u8 PHYSR1;
1064 volatile u8 MIICR; 1032 volatile u8 MIICR;
1065 volatile u8 MIIADR; 1033 volatile u8 MIIADR;
1066 volatile u16 MIIDATA; 1034 volatile __le16 MIIDATA;
1067 1035
1068 volatile u16 SoftTimer0; /* 0x74 */ 1036 volatile __le16 SoftTimer0; /* 0x74 */
1069 volatile u16 SoftTimer1; 1037 volatile __le16 SoftTimer1;
1070 1038
1071 volatile u8 CFGA; /* 0x78 */ 1039 volatile u8 CFGA; /* 0x78 */
1072 volatile u8 CFGB; 1040 volatile u8 CFGB;
1073 volatile u8 CFGC; 1041 volatile u8 CFGC;
1074 volatile u8 CFGD; 1042 volatile u8 CFGD;
1075 1043
1076 volatile u16 DCFG; /* 0x7C */ 1044 volatile __le16 DCFG; /* 0x7C */
1077 volatile u16 MCFG; 1045 volatile __le16 MCFG;
1078 1046
1079 volatile u8 TBIST; /* 0x80 */ 1047 volatile u8 TBIST; /* 0x80 */
1080 volatile u8 RBIST; 1048 volatile u8 RBIST;
@@ -1086,9 +1054,9 @@ struct mac_regs {
1086 volatile u8 rev_id; 1054 volatile u8 rev_id;
1087 volatile u8 PORSTS; 1055 volatile u8 PORSTS;
1088 1056
1089 volatile u32 MIBData; /* 0x88 */ 1057 volatile __le32 MIBData; /* 0x88 */
1090 1058
1091 volatile u16 EEWrData; 1059 volatile __le16 EEWrData;
1092 1060
1093 volatile u8 reserved_8E; 1061 volatile u8 reserved_8E;
1094 volatile u8 BPMDWr; 1062 volatile u8 BPMDWr;
@@ -1098,7 +1066,7 @@ struct mac_regs {
1098 volatile u8 EECHKSUM; /* 0x92 */ 1066 volatile u8 EECHKSUM; /* 0x92 */
1099 volatile u8 EECSR; 1067 volatile u8 EECSR;
1100 1068
1101 volatile u16 EERdData; /* 0x94 */ 1069 volatile __le16 EERdData; /* 0x94 */
1102 volatile u8 EADDR; 1070 volatile u8 EADDR;
1103 volatile u8 EMBCMD; 1071 volatile u8 EMBCMD;
1104 1072
@@ -1112,22 +1080,22 @@ struct mac_regs {
1112 volatile u8 DEBUG; 1080 volatile u8 DEBUG;
1113 volatile u8 CHIPGCR; 1081 volatile u8 CHIPGCR;
1114 1082
1115 volatile u16 WOLCRSet; /* 0xA0 */ 1083 volatile __le16 WOLCRSet; /* 0xA0 */
1116 volatile u8 PWCFGSet; 1084 volatile u8 PWCFGSet;
1117 volatile u8 WOLCFGSet; 1085 volatile u8 WOLCFGSet;
1118 1086
1119 volatile u16 WOLCRClr; /* 0xA4 */ 1087 volatile __le16 WOLCRClr; /* 0xA4 */
1120 volatile u8 PWCFGCLR; 1088 volatile u8 PWCFGCLR;
1121 volatile u8 WOLCFGClr; 1089 volatile u8 WOLCFGClr;
1122 1090
1123 volatile u16 WOLSRSet; /* 0xA8 */ 1091 volatile __le16 WOLSRSet; /* 0xA8 */
1124 volatile u16 reserved_AA; 1092 volatile __le16 reserved_AA;
1125 1093
1126 volatile u16 WOLSRClr; /* 0xAC */ 1094 volatile __le16 WOLSRClr; /* 0xAC */
1127 volatile u16 reserved_AE; 1095 volatile __le16 reserved_AE;
1128 1096
1129 volatile u16 PatternCRC[8]; /* 0xB0 */ 1097 volatile __le16 PatternCRC[8]; /* 0xB0 */
1130 volatile u32 ByteMask[4][4]; /* 0xC0 */ 1098 volatile __le32 ByteMask[4][4]; /* 0xC0 */
1131} __attribute__ ((__packed__)); 1099} __attribute__ ((__packed__));
1132 1100
1133 1101
@@ -1238,12 +1206,12 @@ typedef u8 MCAM_ADDR[ETH_ALEN];
1238struct arp_packet { 1206struct arp_packet {
1239 u8 dest_mac[ETH_ALEN]; 1207 u8 dest_mac[ETH_ALEN];
1240 u8 src_mac[ETH_ALEN]; 1208 u8 src_mac[ETH_ALEN];
1241 u16 type; 1209 __be16 type;
1242 u16 ar_hrd; 1210 __be16 ar_hrd;
1243 u16 ar_pro; 1211 __be16 ar_pro;
1244 u8 ar_hln; 1212 u8 ar_hln;
1245 u8 ar_pln; 1213 u8 ar_pln;
1246 u16 ar_op; 1214 __be16 ar_op;
1247 u8 ar_sha[ETH_ALEN]; 1215 u8 ar_sha[ETH_ALEN];
1248 u8 ar_sip[4]; 1216 u8 ar_sip[4];
1249 u8 ar_tha[ETH_ALEN]; 1217 u8 ar_tha[ETH_ALEN];
@@ -1253,7 +1221,7 @@ struct arp_packet {
1253struct _magic_packet { 1221struct _magic_packet {
1254 u8 dest_mac[6]; 1222 u8 dest_mac[6];
1255 u8 src_mac[6]; 1223 u8 src_mac[6];
1256 u16 type; 1224 __be16 type;
1257 u8 MAC[16][6]; 1225 u8 MAC[16][6];
1258 u8 password[6]; 1226 u8 password[6];
1259} __attribute__ ((__packed__)); 1227} __attribute__ ((__packed__));