via-velocity big-endian support
Subsystems (2)
PATCH 1/1 via-velocity big-endian support
* killed multibyte bitfields in fixed-endian structs
* annotated
* added conversions where needed
* fixed a couple of obvious brainos in (ifdefed out) zerocopy
stuff
Note that it's absofsckinglutely untested. It should not give differences in behaviour on l-e, but that's in the famous last words category...
Review and testing is welcome.
---
drivers/net/via-velocity.c +46 -41
@@ -681,7 +681,7 @@ static void velocity_rx_reset(struct velocity_info *vptr)* Init state, all RD entries belong to the NIC */ for (i =0 ; i < vptr->options.numrx; ++i) - vptr->rd_ring[i].rdesc0.owner =OWNED_BY_NIC ; + vptr->rd_ring[i].rdesc0.len |=OWNED_BY_NIC ;writew (vptr->options.numrx, ®s->RBRDU);writel (vptr->rd_pool_dma, ®s->RDBaseLo);
@@ -777,7 +777,7 @@ static void velocity_init_registers(struct velocity_info *vptr, vptr->int_mask =INT_MASK_DEF ; -writel (cpu_to_le32 (vptr->rd_pool_dma), ®s->RDBaseLo); +writel (vptr->rd_pool_dma, ®s->RDBaseLo);writew (vptr->options.numrx -1 , ®s->RDCSize);mac_rx_queue_run (regs);mac_rx_queue_wake (regs);
@@ -785,7 +785,7 @@ static void velocity_init_registers(struct velocity_info *vptr,writew (vptr->options.numtx -1 , ®s->TDCSize);for (i =0 ; i < vptr->num_txq; i++) { -writel (cpu_to_le32 (vptr->td_pool_dma[i]), &(regs->TDBaseLo[i])); +writel (vptr->td_pool_dma[i], ®s->TDBaseLo[i]);mac_tx_queue_run (regs, i); }
@@ -1195,7 +1195,7 @@ static inline void velocity_give_many_rx_descs(struct velocity_info *vptr) dirty = vptr->rd_dirty - unusable;for (avail = vptr->rd_filled &0xfffc ; avail; avail--) { dirty = (dirty >0 ) ? dirty -1 : vptr->options.numrx -1 ; - vptr->rd_ring[dirty].rdesc0.owner =OWNED_BY_NIC ; + vptr->rd_ring[dirty].rdesc0.len |=OWNED_BY_NIC ; }writew (vptr->rd_filled &0xfffc , ®s->RBRDU);
@@ -1210,7 +1210,7 @@ static int velocity_rx_refill(struct velocity_info *vptr)struct rx_desc *rd = vptr->rd_ring + dirty;/* Fine for an all zero Rx desc at init time as well */ -if (rd->rdesc0.owner ==OWNED_BY_NIC ) +if (rd->rdesc0.len &OWNED_BY_NIC )break ;if (!vptr->rd_info[dirty].skb) {
@@ -1409,31 +1409,33 @@ static int velocity_rx_srv(struct velocity_info *vptr, int status) do { struct rx_desc *rd = vptr->rd_ring + rd_curr; + u16 rsr; if (!vptr->rd_info[rd_curr].skb) break; - if (rd->rdesc0.owner == OWNED_BY_NIC) + if (rd->rdesc0.len & OWNED_BY_NIC) break; rmb(); + rsr = le16_to_cpu(rd->rdesc0.RSR); /* * Don't drop CE or RL error frame although RXOK is off */ - if ((rd->rdesc0.RSR & RSR_RXOK) || (!(rd->rdesc0.RSR & RSR_RXOK) && (rd->rdesc0.RSR & (RSR_CE | RSR_RL)))) { + if (rsr & (RSR_RXOK | RSR_CE | RSR_RL)) { if (velocity_receive_frame(vptr, rd_curr) < 0) stats->rx_dropped++; } else { - if (rd->rdesc0.RSR & RSR_CRC) + if (rsr & RSR_CRC) stats->rx_crc_errors++; - if (rd->rdesc0.RSR & RSR_FAE) + if (rsr & RSR_FAE) stats->rx_frame_errors++; stats->rx_dropped++; } - rd->inten = 1; + rd->size |= RX_INTEN; vptr->dev->last_rx = jiffies;
@@ -1554,16 +1556,17 @@ static int velocity_receive_frame(struct velocity_info *vptr, int idx)struct net_device_stats *stats = &vptr->stats;struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]);struct rx_desc *rd = &(vptr->rd_ring[idx]); -int pkt_len = rd->rdesc0.len; +int pkt_len =le16_to_cpu (rd->rdesc0.len) &0x3fff ; +u16 rsr =le16_to_cpu (rd->rdesc0.RSR);struct sk_buff *skb; -if (rd->rdesc0.RSR & (RSR_STP |RSR_EDP )) { +if (rsr & (RSR_STP |RSR_EDP )) {VELOCITY_PRT (MSG_LEVEL_VERBOSE ,KERN_ERR " %s : the received frame span multple RDs.\n" , vptr->dev->name); stats->rx_length_errors++;return -EINVAL ; } -if (rd->rdesc0.RSR &RSR_MAR ) +if (rsr &RSR_MAR ) vptr->stats.multicast++; skb = rd_info->skb;
@@ -1576,7 +1579,7 @@ static int velocity_receive_frame(struct velocity_info *vptr, int idx)*/ if (vptr->flags &VELOCITY_FLAGS_VAL_PKT_LEN ) { -if (rd->rdesc0.RSR &RSR_RL ) { +if (rsr &RSR_RL ) { stats->rx_length_errors++;return -EINVAL ; }
@@ -1637,8 +1640,7 @@ static int velocity_alloc_rx_buf(struct velocity_info *vptr, int idx)*/ *((u32 *) & (rd->rdesc0)) =0 ; - rd->len =cpu_to_le32 (vptr->rx_buf_sz); - rd->inten =1 ; + rd->size =cpu_to_le16 (vptr->rx_buf_sz) |RX_INTEN ; rd->pa_low =cpu_to_le32 (rd_info->skb_dma); rd->pa_high =0 ;return 0 ;
@@ -1663,6 +1665,7 @@ static int velocity_tx_srv(struct velocity_info *vptr, u32 status)int works =0 ;struct velocity_td_info *tdinfo;struct net_device_stats *stats = &vptr->stats; +u16 tsr;for (qnum =0 ; qnum < vptr->num_txq; qnum++) { for (idx = vptr->td_tail[qnum]; vptr->td_used[qnum] > 0;
@@ -1674,22 +1677,24 @@ static int velocity_tx_srv(struct velocity_info *vptr, u32 status) td = &(vptr->td_rings[qnum][idx]); tdinfo = &(vptr->td_infos[qnum][idx]); -if (td->tdesc0.owner ==OWNED_BY_NIC ) +if (td->tdesc0.len &OWNED_BY_NIC )break ;if ((works++ >15 ))break ; + + tsr =le16_to_cpu (td->tdesc0.TSR); -if (td->tdesc0.TSR &TSR0_TERR ) { +if (tsr &TSR0_TERR ) { stats->tx_errors++; stats->tx_dropped++; -if (td->tdesc0.TSR &TSR0_CDH ) +if (tsr &TSR0_CDH ) stats->tx_heartbeat_errors++; -if (td->tdesc0.TSR &TSR0_CRS ) +if (tsr &TSR0_CRS ) stats->tx_carrier_errors++; -if (td->tdesc0.TSR &TSR0_ABT ) +if (tsr &TSR0_ABT ) stats->tx_aborted_errors++; -if (td->tdesc0.TSR &TSR0_OWC ) +if (tsr &TSR0_OWC ) stats->tx_window_errors++; }else { stats->tx_packets++;
@@ -1874,7 +1879,7 @@ static void velocity_free_tx_buf(struct velocity_info *vptr, struct velocity_td_for (i =0 ; i < tdinfo->nskb_dma; i++) {#ifdef VELOCITY_ZERO_COPY_SUPPORT -pci_unmap_single (vptr->pdev, tdinfo->skb_dma[i], td->tdesc1.len,PCI_DMA_TODEVICE ); +pci_unmap_single (vptr->pdev, tdinfo->skb_dma[i],le16_to_cpu (td->tdesc1.len),PCI_DMA_TODEVICE );#else pci_unmap_single (vptr->pdev, tdinfo->skb_dma[i], skb->len,PCI_DMA_TODEVICE );#endif
@@ -2067,8 +2072,8 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)struct velocity_td_info *tdinfo;unsigned long flags;int index; -int pktlen = skb->len; +__le16 len =cpu_to_le16 (pktlen);#ifdef VELOCITY_ZERO_COPY_SUPPORT if (skb_shinfo (skb)->nr_frags >6 &&__skb_linearize (skb)) {
@@ -2085,7 +2090,7 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev) td_ptr->tdesc1.TCPLS =TCPLS_NORMAL ; td_ptr->tdesc1.TCR =TCR0_TIC ; - td_ptr->td_buf[0 ].queue =0 ; + td_ptr->td_buf[0 ].size &= ~TD_QUEUE ;/* * Pad short frames.
@@ -2093,14 +2098,15 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)if (pktlen <ETH_ZLEN ) {/* Cannot occur until ZC support */ pktlen =ETH_ZLEN ; + len =cpu_to_le16 (ETH_ZLEN );skb_copy_from_linear_data (skb, tdinfo->buf, skb->len);memset (tdinfo->buf + skb->len,0 ,ETH_ZLEN - skb->len); tdinfo->skb = skb; tdinfo->skb_dma[0 ] = tdinfo->buf_dma; - td_ptr->tdesc0.pktsize = pktlen; + td_ptr->tdesc0.len = len; td_ptr->td_buf[0 ].pa_low =cpu_to_le32 (tdinfo->skb_dma[0 ]); td_ptr->td_buf[0 ].pa_high =0 ; - td_ptr->td_buf[0 ].bufsize = td_ptr->tdesc0.pktsize; + td_ptr->td_buf[0 ].size = len;/* queue is 0 anyway */ tdinfo->nskb_dma =1 ; td_ptr->tdesc1.CMDZ =2 ; }else
@@ -2111,10 +2117,10 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)if (nfrags >6 ) {skb_copy_from_linear_data (skb, tdinfo->buf, skb->len); tdinfo->skb_dma[0 ] = tdinfo->buf_dma; - td_ptr->tdesc0.pktsize = + td_ptr->tdesc0.len = len; td_ptr->td_buf[0 ].pa_low =cpu_to_le32 (tdinfo->skb_dma[0 ]); td_ptr->td_buf[0 ].pa_high =0 ; - td_ptr->td_buf[0 ].bufsize = td_ptr->tdesc0.pktsize; + td_ptr->td_buf[0 ].size = len;/* queue is 0 anyway */ tdinfo->nskb_dma =1 ; td_ptr->tdesc1.CMDZ =2 ; }else {
@@ -2122,22 +2128,23 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev) tdinfo->nskb_dma =0 ; tdinfo->skb_dma[i] =pci_map_single (vptr->pdev, skb->data, skb->len - skb->data_len,PCI_DMA_TODEVICE ); - td_ptr->tdesc0.pktsize = pktlen; + td_ptr->tdesc0.len = len;/* FIXME: support 48bit DMA later */ td_ptr->td_buf[i].pa_low =cpu_to_le32 (tdinfo->skb_dma); td_ptr->td_buf[i].pa_high =0 ; - td_ptr->td_buf[i].bufsize = skb->len->skb->data_len; + td_ptr->td_buf[i].size = +cpu_to_le16 (skb->len->skb->data_len);for (i =0 ; i < nfrags; i++) {skb_frag_t *frag = &skb_shinfo (skb)->frags[i]; -void *addr = ((void *)page_address (frag->page + frag->page_offset)); +void *addr = (void *)page_address (frag->page) + frag->page_offset; tdinfo->skb_dma[i +1 ] =pci_map_single (vptr->pdev, addr, frag->size,PCI_DMA_TODEVICE ); td_ptr->td_buf[i +1 ].pa_low =cpu_to_le32 (tdinfo->skb_dma[i +1 ]); td_ptr->td_buf[i +1 ].pa_high =0 ; - td_ptr->td_buf[i +1 ].bufsize = frag->size; + td_ptr->td_buf[i +1 ].size =cpu_to_le16 (frag->size); } tdinfo->nskb_dma = i -1 ; td_ptr->tdesc1.CMDZ = i;
@@ -2152,18 +2159,16 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)*/ tdinfo->skb = skb; tdinfo->skb_dma[0 ] =pci_map_single (vptr->pdev, skb->data, pktlen,PCI_DMA_TODEVICE ); - td_ptr->tdesc0.pktsize = pktlen; + td_ptr->tdesc0.len = len; td_ptr->td_buf[0 ].pa_low =cpu_to_le32 (tdinfo->skb_dma[0 ]); td_ptr->td_buf[0 ].pa_high =0 ; - td_ptr->td_buf[0 ].bufsize = td_ptr->tdesc0.pktsize; + td_ptr->td_buf[0 ].size = len; tdinfo->nskb_dma =1 ; td_ptr->tdesc1.CMDZ =2 ; }if (vptr->vlgrp &&vlan_tx_tag_present (skb)) { - td_ptr->tdesc1.pqinf.VID =vlan_tx_tag_get (skb); - td_ptr->tdesc1.pqinf.priority =0 ; - td_ptr->tdesc1.pqinf.CFI =0 ; + td_ptr->tdesc1.vlan =cpu_to_le16 (vlan_tx_tag_get (skb)); td_ptr->tdesc1.TCR |=TCR0_VETAG ; }
@@ -2185,7 +2190,7 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)if (prev <0 ) prev = vptr->options.numtx -1 ; - td_ptr->tdesc0.owner =OWNED_BY_NIC ; + td_ptr->tdesc0.len |=OWNED_BY_NIC ; vptr->td_used[qnum]++; vptr->td_curr[qnum] = (index +1 ) % vptr->options.numtx;
@@ -2193,7 +2198,7 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)netif_stop_queue (dev); td_ptr = &(vptr->td_rings[qnum][prev]); - td_ptr->td_buf[0 ].queue =1 ; + td_ptr->td_buf[0 ].size |=TD_QUEUE ;mac_tx_queue_wake (vptr->mac_regs, qnum); } dev->trans_start = jiffies;
@@ -3410,7 +3415,7 @@ static int velocity_suspend(struct pci_dev *pdev, pm_message_t state)velocity_save_context (vptr, &vptr->context);velocity_shutdown (vptr);velocity_set_wol (vptr); -pci_enable_wake (pdev,3 ,1 ); +pci_enable_wake (pdev, PCI_D3hot,1 );pci_set_power_state (pdev, PCI_D3hot); }else {velocity_save_context (vptr, &vptr->context);
drivers/net/via-velocity.h +66 -69
251 lines not on this page · raw message
Al Viro <[email protected]> :
[...]
drivers/net/via-velocity.h line 200
Quoted 10 lines
drivers/net/via-velocity.h +2
-0@@ -196,26 +196,29 @@* Receive descriptor */ +#define DESC_OWNER cpu_to_le16(0x8000) +
DESC_OWNER does not seem to be used.
[...]
drivers/net/via-velocity.h line 214
Quoted 3 lines
drivers/net/via-velocity.h +3
-0+enum { +RX_INTEN =__constant_cpu_to_le16 (0x8000 ) +};
Can we avoid using cpu_to_leXY here for consistency sake within the driver (and among different drivers as well) ?
Signature · 1 line
Ueimor
Quoted 4 lines · Francois Romieu
Review
Quoted 2 lines
(quoted diff) +2
-0+#define DESC_OWNER cpu_to_le16(0x8000) +
DESC_OWNERdoes not seem to be used.
*nod*
That should be removed.
Quoted 7 lines
[...]
drivers/net/via-velocity.h line 214
Quoted 3 lines
drivers/net/via-velocity.h +3
-0+enum { +RX_INTEN =__constant_cpu_to_le16 (0x8000 ) +};Can we avoid using
cpu_to_leXYhere for consistency sake within the driver (and among different drivers as well) ?
???
What is the problem with having such constants? If you mean "could we use cpu_to_le16() instead of __constant_cpu_to_le16()", the answer's no - that's one of the very few places where __constant_.... form is needed (other are case <...>: and initializers for non-auto variables).
Al Viro <[email protected]> :
[...]
Quoted 4 lines
Quoted 2 lines
Can we avoid using
cpu_to_leXYhere for consistency sake within the driver (and among different drivers as well) ????
I admit that it is a bit late for the Xmas wishlist. Compare it with:
@@ -1409,31 +1409,33 @@ static int velocity_rx_srv(struct velocity_info *vptr, int status)
do {
struct rx_desc *rd = vptr->rd_ring + rd_curr;+ u16 rsr;
[...]
+ rsr = le16_to_cpu(rd->rdesc0.RSR);
[...]
- if (rd->rdesc0.RSR & RSR_CRC)
+ if (rsr & RSR_CRC)
^^^^^^^ this one is #define RSR_CRC 0x0002
-> some descriptor bits are now declared with an explicit endianness
while others are not (whence "u16 rsr" where "__le16 rsr" whould have fit). Both are fine but it would not hurt to stick with one convention in a given driver.
Signature · 1 line
Ueimor
Quoted 4 lines · Francois Romieu
-> some descriptor bits are now declared with an explicit endianness
while others are not (whence "u16 rsr" where "__le16rsr" whould have fit). Both are fine but it would not hurt to stick with one convention in a given driver.
Point taken...
* kill multibyte bitfields
* annotate
* add missing conversions
* fix a couple of brainos in zerocopy stuff (fortunately, it's ifdef'ed out)
--- drivers/net/via-velocity.c | 62 ++++++------- drivers/net/via-velocity.h | 220 +++++++++++++++++++------------------------- 2 files changed, 125 insertions(+), 157 deletions(-)
drivers/net/via-velocity.c +30 -32
@@ -8,7 +8,6 @@* for 64bit hardware platforms. * * TODO -* Big-endian support * rx_copybreak/alignment * Scatter gather * More testing
@@ -681,7 +680,7 @@ static void velocity_rx_reset(struct velocity_info *vptr)* Init state, all RD entries belong to the NIC */ for (i =0 ; i < vptr->options.numrx; ++i) - vptr->rd_ring[i].rdesc0.owner =OWNED_BY_NIC ; + vptr->rd_ring[i].rdesc0.len |=OWNED_BY_NIC ;writew (vptr->options.numrx, ®s->RBRDU);writel (vptr->rd_pool_dma, ®s->RDBaseLo);
@@ -777,7 +776,7 @@ static void velocity_init_registers(struct velocity_info *vptr, vptr->int_mask =INT_MASK_DEF ; -writel (cpu_to_le32 (vptr->rd_pool_dma), ®s->RDBaseLo); +writel (vptr->rd_pool_dma, ®s->RDBaseLo);writew (vptr->options.numrx -1 , ®s->RDCSize);mac_rx_queue_run (regs);mac_rx_queue_wake (regs);
@@ -785,7 +784,7 @@ static void velocity_init_registers(struct velocity_info *vptr,writew (vptr->options.numtx -1 , ®s->TDCSize);for (i =0 ; i < vptr->num_txq; i++) { -writel (cpu_to_le32 (vptr->td_pool_dma[i]), &(regs->TDBaseLo[i])); +writel (vptr->td_pool_dma[i], ®s->TDBaseLo[i]);mac_tx_queue_run (regs, i); }
@@ -1195,7 +1194,7 @@ static inline void velocity_give_many_rx_descs(struct velocity_info *vptr) dirty = vptr->rd_dirty - unusable;for (avail = vptr->rd_filled &0xfffc ; avail; avail--) { dirty = (dirty >0 ) ? dirty -1 : vptr->options.numrx -1 ; - vptr->rd_ring[dirty].rdesc0.owner =OWNED_BY_NIC ; + vptr->rd_ring[dirty].rdesc0.len |=OWNED_BY_NIC ; }writew (vptr->rd_filled &0xfffc , ®s->RBRDU);
@@ -1210,7 +1209,7 @@ static int velocity_rx_refill(struct velocity_info *vptr)struct rx_desc *rd = vptr->rd_ring + dirty;/* Fine for an all zero Rx desc at init time as well */ -if (rd->rdesc0.owner ==OWNED_BY_NIC ) +if (rd->rdesc0.len &OWNED_BY_NIC )break ;if (!vptr->rd_info[dirty].skb) {
@@ -1413,7 +1412,7 @@ static int velocity_rx_srv(struct velocity_info *vptr, int status)if (!vptr->rd_info[rd_curr].skb)break ; -if (rd->rdesc0.owner ==OWNED_BY_NIC ) +if (rd->rdesc0.len &OWNED_BY_NIC )break ;rmb ();
@@ -1421,7 +1420,7 @@ static int velocity_rx_srv(struct velocity_info *vptr, int status)/* * Don't drop CE or RL error frame although RXOK is off */ -if ((rd->rdesc0.RSR &RSR_RXOK ) || (!(rd->rdesc0.RSR &RSR_RXOK ) && (rd->rdesc0.RSR & (RSR_CE |RSR_RL )))) { +if (rd->rdesc0.RSR & (RSR_RXOK |RSR_CE |RSR_RL )) {if (velocity_receive_frame (vptr, rd_curr) <0 ) stats->rx_dropped++; }else {
@@ -1433,7 +1432,7 @@ static int velocity_rx_srv(struct velocity_info *vptr, int status) stats->rx_dropped++; } - rd->inten =1 ; + rd->size |=RX_INTEN ; vptr->dev->last_rx = jiffies;
@@ -1554,7 +1553,7 @@ static int velocity_receive_frame(struct velocity_info *vptr, int idx)struct net_device_stats *stats = &vptr->stats;struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]);struct rx_desc *rd = &(vptr->rd_ring[idx]); -int pkt_len = rd->rdesc0.len; +int pkt_len =le16_to_cpu (rd->rdesc0.len) &0x3fff ;struct sk_buff *skb;if (rd->rdesc0.RSR & (RSR_STP |RSR_EDP )) {
@@ -1637,8 +1636,7 @@ static int velocity_alloc_rx_buf(struct velocity_info *vptr, int idx)*/ *((u32 *) & (rd->rdesc0)) =0 ; - rd->len =cpu_to_le32 (vptr->rx_buf_sz); - rd->inten =1 ; + rd->size =cpu_to_le16 (vptr->rx_buf_sz) |RX_INTEN ; rd->pa_low =cpu_to_le32 (rd_info->skb_dma); rd->pa_high =0 ;return 0 ;
@@ -1674,7 +1672,7 @@ static int velocity_tx_srv(struct velocity_info *vptr, u32 status) td = &(vptr->td_rings[qnum][idx]); tdinfo = &(vptr->td_infos[qnum][idx]); -if (td->tdesc0.owner ==OWNED_BY_NIC ) +if (td->tdesc0.len &OWNED_BY_NIC )break ;if ((works++ >15 ))
@@ -1874,7 +1872,7 @@ static void velocity_free_tx_buf(struct velocity_info *vptr, struct velocity_td_for (i =0 ; i < tdinfo->nskb_dma; i++) {#ifdef VELOCITY_ZERO_COPY_SUPPORT -pci_unmap_single (vptr->pdev, tdinfo->skb_dma[i], td->tdesc1.len,PCI_DMA_TODEVICE ); +pci_unmap_single (vptr->pdev, tdinfo->skb_dma[i],le16_to_cpu (td->tdesc1.len),PCI_DMA_TODEVICE );#else pci_unmap_single (vptr->pdev, tdinfo->skb_dma[i], skb->len,PCI_DMA_TODEVICE );#endif
@@ -2067,8 +2065,8 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)struct velocity_td_info *tdinfo;unsigned long flags;int index; -int pktlen = skb->len; +__le16 len =cpu_to_le16 (pktlen);#ifdef VELOCITY_ZERO_COPY_SUPPORT if (skb_shinfo (skb)->nr_frags >6 &&__skb_linearize (skb)) {
@@ -2085,7 +2083,7 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev) td_ptr->tdesc1.TCPLS =TCPLS_NORMAL ; td_ptr->tdesc1.TCR =TCR0_TIC ; - td_ptr->td_buf[0 ].queue =0 ; + td_ptr->td_buf[0 ].size &= ~TD_QUEUE ;/* * Pad short frames.
@@ -2093,14 +2091,15 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)if (pktlen <ETH_ZLEN ) {/* Cannot occur until ZC support */ pktlen =ETH_ZLEN ; + len =cpu_to_le16 (ETH_ZLEN );skb_copy_from_linear_data (skb, tdinfo->buf, skb->len);memset (tdinfo->buf + skb->len,0 ,ETH_ZLEN - skb->len); tdinfo->skb = skb; tdinfo->skb_dma[0 ] = tdinfo->buf_dma; - td_ptr->tdesc0.pktsize = pktlen; + td_ptr->tdesc0.len = len; td_ptr->td_buf[0 ].pa_low =cpu_to_le32 (tdinfo->skb_dma[0 ]); td_ptr->td_buf[0 ].pa_high =0 ; - td_ptr->td_buf[0 ].bufsize = td_ptr->tdesc0.pktsize; + td_ptr->td_buf[0 ].size = len;/* queue is 0 anyway */ tdinfo->nskb_dma =1 ; td_ptr->tdesc1.CMDZ =2 ; }else
@@ -2111,10 +2110,10 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)if (nfrags >6 ) {skb_copy_from_linear_data (skb, tdinfo->buf, skb->len); tdinfo->skb_dma[0 ] = tdinfo->buf_dma; - td_ptr->tdesc0.pktsize = + td_ptr->tdesc0.len = len; td_ptr->td_buf[0 ].pa_low =cpu_to_le32 (tdinfo->skb_dma[0 ]); td_ptr->td_buf[0 ].pa_high =0 ; - td_ptr->td_buf[0 ].bufsize = td_ptr->tdesc0.pktsize; + td_ptr->td_buf[0 ].size = len;/* queue is 0 anyway */ tdinfo->nskb_dma =1 ; td_ptr->tdesc1.CMDZ =2 ; }else {
@@ -2122,22 +2121,23 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev) tdinfo->nskb_dma =0 ; tdinfo->skb_dma[i] =pci_map_single (vptr->pdev, skb->data, skb->len - skb->data_len,PCI_DMA_TODEVICE ); - td_ptr->tdesc0.pktsize = pktlen; + td_ptr->tdesc0.len = len;/* FIXME: support 48bit DMA later */ td_ptr->td_buf[i].pa_low =cpu_to_le32 (tdinfo->skb_dma); td_ptr->td_buf[i].pa_high =0 ; - td_ptr->td_buf[i].bufsize = skb->len->skb->data_len; + td_ptr->td_buf[i].size = +cpu_to_le16 (skb->len->skb->data_len);for (i =0 ; i < nfrags; i++) {skb_frag_t *frag = &skb_shinfo (skb)->frags[i]; -void *addr = ((void *)page_address (frag->page + frag->page_offset)); +void *addr = (void *)page_address (frag->page) + frag->page_offset; tdinfo->skb_dma[i +1 ] =pci_map_single (vptr->pdev, addr, frag->size,PCI_DMA_TODEVICE ); td_ptr->td_buf[i +1 ].pa_low =cpu_to_le32 (tdinfo->skb_dma[i +1 ]); td_ptr->td_buf[i +1 ].pa_high =0 ; - td_ptr->td_buf[i +1 ].bufsize = frag->size; + td_ptr->td_buf[i +1 ].size =cpu_to_le16 (frag->size); } tdinfo->nskb_dma = i -1 ; td_ptr->tdesc1.CMDZ = i;
@@ -2152,18 +2152,16 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)*/ tdinfo->skb = skb; tdinfo->skb_dma[0 ] =pci_map_single (vptr->pdev, skb->data, pktlen,PCI_DMA_TODEVICE ); - td_ptr->tdesc0.pktsize = pktlen; + td_ptr->tdesc0.len = len; td_ptr->td_buf[0 ].pa_low =cpu_to_le32 (tdinfo->skb_dma[0 ]); td_ptr->td_buf[0 ].pa_high =0 ; - td_ptr->td_buf[0 ].bufsize = td_ptr->tdesc0.pktsize; + td_ptr->td_buf[0 ].size = len; tdinfo->nskb_dma =1 ; td_ptr->tdesc1.CMDZ =2 ; }if (vptr->vlgrp &&vlan_tx_tag_present (skb)) { - td_ptr->tdesc1.pqinf.VID =vlan_tx_tag_get (skb); - td_ptr->tdesc1.pqinf.priority =0 ; - td_ptr->tdesc1.pqinf.CFI =0 ; + td_ptr->tdesc1.vlan =cpu_to_le16 (vlan_tx_tag_get (skb)); td_ptr->tdesc1.TCR |=TCR0_VETAG ; }
@@ -2185,7 +2183,7 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)if (prev <0 ) prev = vptr->options.numtx -1 ; - td_ptr->tdesc0.owner =OWNED_BY_NIC ; + td_ptr->tdesc0.len |=OWNED_BY_NIC ; vptr->td_used[qnum]++; vptr->td_curr[qnum] = (index +1 ) % vptr->options.numtx;
@@ -2193,7 +2191,7 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)netif_stop_queue (dev); td_ptr = &(vptr->td_rings[qnum][prev]); - td_ptr->td_buf[0 ].queue =1 ; + td_ptr->td_buf[0 ].size |=TD_QUEUE ;mac_tx_queue_wake (vptr->mac_regs, qnum); } dev->trans_start = jiffies;
@@ -3410,7 +3408,7 @@ static int velocity_suspend(struct pci_dev *pdev, pm_message_t state)velocity_save_context (vptr, &vptr->context);velocity_shutdown (vptr);velocity_set_wol (vptr); -pci_enable_wake (pdev,3 ,1 ); +pci_enable_wake (pdev, PCI_D3hot,1 );pci_set_power_state (pdev, PCI_D3hot); }else {velocity_save_context (vptr, &vptr->context);
drivers/net/via-velocity.h +95 -125
352 lines not on this page · raw message
Signature · 1 line
1.5.3.GIT
Al Viro <[email protected]> :
[...]
Quoted 8 lines
Point taken...
* kill multibyte bitfields
* annotate
* add missing conversions
* fix a couple of brainos in zerocopy stuff (fortunately, it's ifdef'ed out)Signed-off-by Al Viro <[email protected]>
Thanks a lot. After the usual xmas delay, split and review, it is available at:
git://git.kernel.org/pub/scm/linux/kernel/git/romieu/netdev-2.6.git velocity
I have shortened the end-of-line comments associated with several #define but the end result is otherwise the same.
Remarks for the random reader below.
Quoted 9 lines
--- drivers/net/via-velocity.c | 62 ++++++------- drivers/net/via-velocity.h | 220 +++++++++++++++++++------------------------- 2 files changed, 125 insertions(+), 157 deletions(-)drivers/net/via-velocity.c +0
-0
[...]
drivers/net/via-velocity.c static void velocity_init_registers(struct velocity_info *vptr, · line 782
Quoted 9 lines
drivers/net/via-velocity.c +1
-1@@ -777,7 +776,7 @@ static void velocity_init_registers(struct velocity_info *vptr, vptr->int_mask =INT_MASK_DEF ; -writel (cpu_to_le32 (vptr->rd_pool_dma), ®s->RDBaseLo); +writel (vptr->rd_pool_dma, ®s->RDBaseLo);writew (vptr->options.numrx -1 , ®s->RDCSize);mac_rx_queue_run (regs);mac_rx_queue_wake (regs);
The cpu_to_le32 was probably wrong in the first place.
[...]
drivers/net/via-velocity.c static void velocity_init_registers(struct velocity_info *vptr, · line 790
Quoted 9 lines
drivers/net/via-velocity.c +1
-1@@ -785,7 +784,7 @@ static void velocity_init_registers(struct velocity_info *vptr,writew (vptr->options.numtx -1 , ®s->TDCSize);for (i =0 ; i < vptr->num_txq; i++) { -writel (cpu_to_le32 (vptr->td_pool_dma[i]), &(regs->TDBaseLo[i])); +writel (vptr->td_pool_dma[i], ®s->TDBaseLo[i]);mac_tx_queue_run (regs, i); }
Same thing.
[...]
drivers/net/via-velocity.c static int velocity_rx_srv(struct velocity_info *vptr, int status) · line 1426
Quoted 9 lines
drivers/net/via-velocity.c +1
-1@@ -1421,7 +1420,7 @@ static int velocity_rx_srv(struct velocity_info *vptr, int status)/* * Don't drop CE or RL error frame although RXOK is off */ -if ((rd->rdesc0.RSR &RSR_RXOK ) || (!(rd->rdesc0.RSR &RSR_RXOK ) && (rd->rdesc0.RSR & (RSR_CE |RSR_RL )))) { +if (rd->rdesc0.RSR & (RSR_RXOK |RSR_CE |RSR_RL )) {if (velocity_receive_frame (vptr, rd_curr) <0 ) stats->rx_dropped++; }else {
This one was fun.
[...]
drivers/net/via-velocity.c static int velocity_xmit(struct sk_buff *skb, struct net_device *dev) · line 2130
Quoted 13 lines
drivers/net/via-velocity.c +3
-2@@ -2122,22 +2121,23 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev) tdinfo->nskb_dma =0 ; tdinfo->skb_dma[i] =pci_map_single (vptr->pdev, skb->data, skb->len - skb->data_len,PCI_DMA_TODEVICE ); - td_ptr->tdesc0.pktsize = pktlen; + td_ptr->tdesc0.len = len;/* FIXME: support 48bit DMA later */ td_ptr->td_buf[i].pa_low =cpu_to_le32 (tdinfo->skb_dma); td_ptr->td_buf[i].pa_high =0 ; - td_ptr->td_buf[i].bufsize = skb->len->skb->data_len; + td_ptr->td_buf[i].size = +cpu_to_le16 (skb->len->skb->data_len);
skb->len->skb->data_len...
Still a bit broken but it is endian clean now. Fine.
Signature · 1 line
Ueimor
It doesn't look like you need a test report, but here's one anyway... I grabbed the patch series from git and am running it successfully right now.