root/trunk/patches/2.6.22/12-velocity-BE.patch

Revision 833, 28.4 kB (checked in by blaster8, 3 years ago)

Archive old versions, add 2.6.22 devel patchset

  • linux-2.6.22-rc1-arm/drivers/net/via-velocity.c

    old new  
    9696MODULE_LICENSE("GPL"); 
    9797MODULE_DESCRIPTION("VIA Networking Velocity Family Gigabit Ethernet Adapter Driver"); 
    9898 
     99/* Valid values for vdebug (additive, this is a bitmask): 
     100 *  0x00 => off 
     101 *  0x01 => always on 
     102 *  0x02 => additional detail on tx (rx, too, if anyone implements same) 
     103 *  0x04 => detail the initialization process 
     104 *  0x08 => spot debug detail; to be used as developers see fit 
     105 */ 
     106static int vdebug = 0; 
     107 
     108/* HAIL - these macros are for the normal 0x01-type tracing... */ 
     109#define HAIL(S) \ 
     110        if (vdebug&1) printk(KERN_NOTICE "%s\n", (S)); 
     111#define HAILS(S,T) \ 
     112        if (vdebug&1) printk(KERN_NOTICE "%s -> status=0x%x\n", (S), (T)); 
     113 
    99114#define VELOCITY_PARAM(N,D) \ 
    100115        static int N[MAX_UNITS]=OPTION_DEFAULT;\ 
    101116        module_param_array(N, int, NULL, 0); \ 
    102117        MODULE_PARM_DESC(N, D); 
    103118 
     119#define VELO_DEBUG_MIN   0 
     120#define VELO_DEBUG_MAX   255 
     121#define VELO_DEBUG_DEF   0 
     122VELOCITY_PARAM(velo_debug, "Debug level"); 
     123 
    104124#define RX_DESC_MIN     64 
    105125#define RX_DESC_MAX     255 
    106126#define RX_DESC_DEF     64 
     
    385405        if (val == -1) 
    386406                *opt = def; 
    387407        else if (val < min || val > max) { 
    388                 VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: the value of parameter %s is invalid, the valid range is (%d-%d)\n", 
    389                                         devname, name, min, max); 
     408                VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "via-velocity: the value of parameter %s is invalid, the valid range is (%d-%d)\n", 
     409                                        name, min, max); 
    390410                *opt = def; 
    391411        } else { 
    392                 VELOCITY_PRT(MSG_LEVEL_INFO, KERN_INFO "%s: set value of parameter %s to %d\n", 
    393                                         devname, name, val); 
     412                VELOCITY_PRT(MSG_LEVEL_INFO, KERN_INFO "via-velocity: set value of parameter %s to %d\n", 
     413                                        name, val); 
    394414                *opt = val; 
    395415        } 
    396416} 
     
    415435        if (val == -1) 
    416436                *opt |= (def ? flag : 0); 
    417437        else if (val < 0 || val > 1) { 
    418                 printk(KERN_NOTICE "%s: the value of parameter %s is invalid, the valid range is (0-1)\n", 
    419                         devname, name); 
     438                printk(KERN_NOTICE "via-velocity: the value of parameter %s is invalid, the valid range is (0-1)\n", 
     439                        name); 
    420440                *opt |= (def ? flag : 0); 
    421441        } else { 
    422                 printk(KERN_INFO "%s: set parameter %s to %s\n", 
    423                         devname, name, val ? "TRUE" : "FALSE"); 
     442                printk(KERN_INFO "via-velocity: set parameter %s to %s\n", 
     443                        name, val ? "TRUE" : "FALSE"); 
    424444                *opt |= (val ? flag : 0); 
    425445        } 
    426446} 
     
    438458static void __devinit velocity_get_options(struct velocity_opt *opts, int index, char *devname) 
    439459{ 
    440460 
     461        velocity_set_int_opt(&opts->velo_debug, velo_debug[index], VELO_DEBUG_MIN, VELO_DEBUG_MAX, VELO_DEBUG_DEF, "velo_debug", devname); 
    441462        velocity_set_int_opt(&opts->rx_thresh, rx_thresh[index], RX_THRESH_MIN, RX_THRESH_MAX, RX_THRESH_DEF, "rx_thresh", devname); 
    442463        velocity_set_int_opt(&opts->DMA_length, DMA_length[index], DMA_LENGTH_MIN, DMA_LENGTH_MAX, DMA_LENGTH_DEF, "DMA_length", devname); 
    443464        velocity_set_int_opt(&opts->numrx, RxDescriptors[index], RX_DESC_MIN, RX_DESC_MAX, RX_DESC_DEF, "RxDescriptors", devname); 
     
    452473        velocity_set_int_opt((int *) &opts->wol_opts, wol_opts[index], WOL_OPT_MIN, WOL_OPT_MAX, WOL_OPT_DEF, "Wake On Lan options", devname); 
    453474        velocity_set_int_opt((int *) &opts->int_works, int_works[index], INT_WORKS_MIN, INT_WORKS_MAX, INT_WORKS_DEF, "Interrupt service works", devname); 
    454475        opts->numrx = (opts->numrx & ~3); 
     476        vdebug = opts->velo_debug; 
    455477} 
    456478 
    457479/** 
     
    466488{ 
    467489        struct mac_regs __iomem * regs = vptr->mac_regs; 
    468490 
     491        HAIL("velocity_init_cam_filter"); 
     492 
    469493        /* Turn on MCFG_PQEN, turn off MCFG_RTGOPT */ 
    470494        WORD_REG_BITS_SET(MCFG_PQEN, MCFG_RTGOPT, &regs->MCFG); 
    471495        WORD_REG_BITS_ON(MCFG_VIDFR, &regs->MCFG); 
     
    484508                        WORD_REG_BITS_ON(MCFG_RTGOPT, &regs->MCFG); 
    485509 
    486510                mac_set_cam(regs, 0, (u8 *) & (vptr->options.vid), VELOCITY_VLAN_ID_CAM); 
    487                 vptr->vCAMmask[0] |= 1; 
    488                 mac_set_cam_mask(regs, vptr->vCAMmask, VELOCITY_VLAN_ID_CAM); 
    489511        } else { 
    490512                u16 temp = 0; 
    491513                mac_set_cam(regs, 0, (u8 *) &temp, VELOCITY_VLAN_ID_CAM); 
    492                 temp = 1; 
    493                 mac_set_cam_mask(regs, (u8 *) &temp, VELOCITY_VLAN_ID_CAM); 
    494514        } 
     515        vptr->vCAMmask[0] |= 1; 
     516        mac_set_cam_mask(regs, vptr->vCAMmask, VELOCITY_VLAN_ID_CAM); 
    495517} 
    496518 
    497519/** 
     
    508530        struct mac_regs __iomem * regs = vptr->mac_regs; 
    509531        int i; 
    510532 
     533        HAIL("velocity_rx_reset"); 
    511534        vptr->rd_dirty = vptr->rd_filled = vptr->rd_curr = 0; 
    512535 
    513536        /* 
    514537         *      Init state, all RD entries belong to the NIC 
    515538         */ 
    516539        for (i = 0; i < vptr->options.numrx; ++i) 
    517                 vptr->rd_ring[i].rdesc0.owner = OWNED_BY_NIC; 
     540                /* vptr->rd_ring[i].rdesc0.owner = OWNED_BY_NIC; BE */ 
     541                vptr->rd_ring[i].rdesc0 |= cpu_to_le32(BE_OWNED_BY_NIC); /* BE */ 
    518542 
    519543        writew(vptr->options.numrx, &regs->RBRDU); 
    520544        writel(vptr->rd_pool_dma, &regs->RDBaseLo); 
     
    537561        struct mac_regs __iomem * regs = vptr->mac_regs; 
    538562        int i, mii_status; 
    539563 
     564        if (vdebug&5) printk(KERN_NOTICE "velocity_init_registers: entering\n"); 
     565 
    540566        mac_wol_reset(regs); 
    541567 
    542568        switch (type) { 
    543569        case VELOCITY_INIT_RESET: 
    544570        case VELOCITY_INIT_WOL: 
    545571 
     572                if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: RESET or WOL\n"); 
    546573                netif_stop_queue(vptr->dev); 
    547574 
    548575                /* 
     
    570597 
    571598        case VELOCITY_INIT_COLD: 
    572599        default: 
     600                if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: COLD or default\n"); 
    573601                /* 
    574602                 *      Do reset 
    575603                 */ 
    576604                velocity_soft_reset(vptr); 
     605                if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: soft reset complete.\n"); 
    577606                mdelay(5); 
    578  
    579607                mac_eeprom_reload(regs); 
    580608                for (i = 0; i < 6; i++) { 
    581609                        writeb(vptr->dev->dev_addr[i], &(regs->PAR[i])); 
     
    593621                 */ 
    594622                BYTE_REG_BITS_SET(CFGB_OFSET, (CFGB_CRANDOM | CFGB_CAP | CFGB_MBA | CFGB_BAKOPT), &regs->CFGB); 
    595623 
     624                if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: Initializing CAM filter\n"); 
    596625                /* 
    597626                 *      Init CAM filter 
    598627                 */ 
     628                if (vdebug&8) printk(KERN_NOTICE "velocity: spot debug: about to init CAM filters\n"); 
     629                mdelay(5);  /* MJW - ARM processors, kernel 2.6.19 - this fixes oopses and hangs */ 
    599630                velocity_init_cam_filter(vptr); 
     631                if (vdebug&8) printk(KERN_NOTICE "velocity: spot debug: init CAM filters complete\n"); 
    600632 
     633                if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: Setting packet filter\n"); 
    601634                /* 
    602635                 *      Set packet filter: Receive directed and broadcast address 
    603636                 */ 
     
    607640                 *      Enable MII auto-polling 
    608641                 */ 
    609642                enable_mii_autopoll(regs); 
     643                if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: enable_mii_autopoll complete.\n"); 
    610644 
    611645                vptr->int_mask = INT_MASK_DEF; 
    612646 
    613                 writel(cpu_to_le32(vptr->rd_pool_dma), &regs->RDBaseLo); 
     647                /* writel(cpu_to_le32(vptr->rd_pool_dma), &regs->RDBaseLo); BE */ 
     648                writel((vptr->rd_pool_dma), &regs->RDBaseLo); /* BE */ 
    614649                writew(vptr->options.numrx - 1, &regs->RDCSize); 
    615650                mac_rx_queue_run(regs); 
    616651                mac_rx_queue_wake(regs); 
     
    618653                writew(vptr->options.numtx - 1, &regs->TDCSize); 
    619654 
    620655                for (i = 0; i < vptr->num_txq; i++) { 
    621                         writel(cpu_to_le32(vptr->td_pool_dma[i]), &(regs->TDBaseLo[i])); 
     656                        /* writel(cpu_to_le32(vptr->td_pool_dma[i]), &(regs->TDBaseLo[i])); BE */ 
     657                        writel((vptr->td_pool_dma[i]), &(regs->TDBaseLo[i])); /* BE */ 
    622658                        mac_tx_queue_run(regs, i); 
    623659                } 
    624660 
     661                if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: DMA settings complete.\n"); 
     662 
    625663                init_flow_control_register(vptr); 
    626664 
    627665                writel(CR0_STOP, &regs->CR0Clr); 
     
    640678 
    641679                enable_flow_control_ability(vptr); 
    642680                mac_hw_mibs_init(regs); 
     681                if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: Set interrupt mask\n"); 
    643682                mac_write_int_mask(vptr->int_mask, regs); 
    644683                mac_clear_isr(regs); 
     684                if (vdebug&4) printk(KERN_NOTICE "velocity_init_registers: complete.\n"); 
    645685 
    646686        } 
    647687} 
     
    659699        struct mac_regs __iomem * regs = vptr->mac_regs; 
    660700        int i = 0; 
    661701 
     702        HAIL("velocity_soft_reset"); 
    662703        writel(CR0_SFRST, &regs->CR0Set); 
    663704 
    664705        for (i = 0; i < W_MAX_TIMEOUT; i++) { 
     
    722763                        VELOCITY_FULL_DRV_NAM, VELOCITY_VERSION); 
    723764                printk(KERN_INFO "Copyright (c) 2002, 2003 VIA Networking Technologies, Inc.\n"); 
    724765                printk(KERN_INFO "Copyright (c) 2004 Red Hat Inc.\n"); 
     766                printk(KERN_INFO "BE support, misc. fixes MJW 01Jan2007 - may be unstable\n"); 
    725767                first = 0; 
    726768        } 
    727769 
     
    935977        dma_addr_t pool_dma; 
    936978        u8 *pool; 
    937979 
     980        HAIL("velocity_init_rings"); 
    938981        /* 
    939982         *      Allocate all RD/TD rings a single pool 
    940983         */ 
     
    9971040static void velocity_free_rings(struct velocity_info *vptr) 
    9981041{ 
    9991042        int size; 
     1043        HAIL("velocity_free_rings"); 
    10001044 
    10011045        size = vptr->options.numrx * sizeof(struct rx_desc) + 
    10021046               vptr->options.numtx * sizeof(struct tx_desc) * vptr->num_txq; 
     
    10131057        struct mac_regs __iomem *regs = vptr->mac_regs; 
    10141058        int avail, dirty, unusable; 
    10151059 
     1060        HAIL("velocity_give_many_rx_descs"); 
    10161061        /* 
    10171062         * RD number must be equal to 4X per hardware spec 
    10181063         * (programming guide rev 1.20, p.13) 
     
    10261071        dirty = vptr->rd_dirty - unusable; 
    10271072        for (avail = vptr->rd_filled & 0xfffc; avail; avail--) { 
    10281073                dirty = (dirty > 0) ? dirty - 1 : vptr->options.numrx - 1; 
    1029                 vptr->rd_ring[dirty].rdesc0.owner = OWNED_BY_NIC; 
     1074                /* vptr->rd_ring[dirty].rdesc0.owner = OWNED_BY_NIC; BE */ 
     1075                vptr->rd_ring[dirty].rdesc0 |= cpu_to_le32(BE_OWNED_BY_NIC); /* BE */ 
    10301076        } 
    10311077 
    10321078        writew(vptr->rd_filled & 0xfffc, &regs->RBRDU); 
     
    10361082static int velocity_rx_refill(struct velocity_info *vptr) 
    10371083{ 
    10381084        int dirty = vptr->rd_dirty, done = 0, ret = 0; 
     1085        HAIL("velocity_rx_refill"); 
    10391086 
    10401087        do { 
    10411088                struct rx_desc *rd = vptr->rd_ring + dirty; 
    10421089 
    10431090                /* Fine for an all zero Rx desc at init time as well */ 
    1044                 if (rd->rdesc0.owner == OWNED_BY_NIC) 
     1091                /* if (rd->rdesc0.owner == OWNED_BY_NIC) BE */ 
     1092                if (rd->rdesc0 & cpu_to_le32(BE_OWNED_BY_NIC)) /* BE */ 
    10451093                        break; 
    10461094 
    10471095                if (!vptr->rd_info[dirty].skb) { 
     
    10761124        unsigned int rsize = sizeof(struct velocity_rd_info) * 
    10771125                                        vptr->options.numrx; 
    10781126 
     1127        HAIL("velocity_init_rd_ring"); 
    10791128        vptr->rd_info = kmalloc(rsize, GFP_KERNEL); 
    10801129        if(vptr->rd_info == NULL) 
    10811130                goto out; 
     
    11051154{ 
    11061155        int i; 
    11071156 
     1157        HAIL("velocity_free_rd_ring"); 
    11081158        if (vptr->rd_info == NULL) 
    11091159                return; 
    11101160 
     
    11461196        unsigned int tsize = sizeof(struct velocity_td_info) * 
    11471197                                        vptr->options.numtx; 
    11481198 
     1199        HAIL("velocity_init_td_ring"); 
    11491200        /* Init the TD ring entries */ 
    11501201        for (j = 0; j < vptr->num_txq; j++) { 
    11511202                curr = vptr->td_pool_dma[j]; 
     
    11821233        struct velocity_td_info * td_info = &(vptr->td_infos[q][n]); 
    11831234        int i; 
    11841235 
     1236        HAIL("velocity_free_td_ring_entry"); 
    11851237        if (td_info == NULL) 
    11861238                return; 
    11871239 
     
    12111263{ 
    12121264        int i, j; 
    12131265 
     1266        HAIL("velocity_free_td_ring"); 
    12141267        for (j = 0; j < vptr->num_txq; j++) { 
    12151268                if (vptr->td_infos[j] == NULL) 
    12161269                        continue; 
     
    12381291        struct net_device_stats *stats = &vptr->stats; 
    12391292        int rd_curr = vptr->rd_curr; 
    12401293        int works = 0; 
     1294        u16 wRSR; /* BE */ 
    12411295 
     1296        HAILS("velocity_rx_srv", status); 
    12421297        do { 
    12431298                struct rx_desc *rd = vptr->rd_ring + rd_curr; 
    12441299 
    12451300                if (!vptr->rd_info[rd_curr].skb) 
    12461301                        break; 
    12471302 
    1248                 if (rd->rdesc0.owner == OWNED_BY_NIC) 
     1303                /* if (rd->rdesc0.owner == OWNED_BY_NIC) BE */ 
     1304                if (rd->rdesc0 & cpu_to_le32(BE_OWNED_BY_NIC)) /* BE */ 
    12491305                        break; 
    12501306 
    12511307                rmb(); 
    12521308 
     1309                wRSR = (u16)(cpu_to_le32(rd->rdesc0)); /* BE */ 
    12531310                /* 
    12541311                 *      Don't drop CE or RL error frame although RXOK is off 
    12551312                 */ 
    1256                 if ((rd->rdesc0.RSR & RSR_RXOK) || (!(rd->rdesc0.RSR & RSR_RXOK) && (rd->rdesc0.RSR & (RSR_CE | RSR_RL)))) { 
     1313                /* if ((rd->rdesc0.RSR & RSR_RXOK) || (!(rd->rdesc0.RSR & RSR_RXOK) && (rd->rdesc0.RSR & (RSR_CE | RSR_RL)))) { BE */ 
     1314                if ((wRSR & RSR_RXOK) || (!(wRSR & RSR_RXOK) && (wRSR & (RSR_CE | RSR_RL)))) { /* BE */ 
    12571315                        if (velocity_receive_frame(vptr, rd_curr) < 0) 
    12581316                                stats->rx_dropped++; 
    12591317                } else { 
    1260                         if (rd->rdesc0.RSR & RSR_CRC) 
     1318                        /* if (rd->rdesc0.RSR & RSR_CRC) BE */ 
     1319                        if (wRSR & RSR_CRC) /* BE */ 
    12611320                                stats->rx_crc_errors++; 
    1262                         if (rd->rdesc0.RSR & RSR_FAE) 
     1321                        /* if (rd->rdesc0.RSR & RSR_FAE) BE */ 
     1322                        if (wRSR & RSR_FAE) /* BE */ 
    12631323                                stats->rx_frame_errors++; 
    12641324 
    12651325                        stats->rx_dropped++; 
    12661326                } 
    12671327 
    1268                 rd->inten = 1; 
     1328                /* rd->inten = 1; BE */ 
     1329                rd->ltwo |= cpu_to_le32(BE_INT_ENABLE); /* BE */ 
    12691330 
    12701331                vptr->dev->last_rx = jiffies; 
    12711332 
     
    12961357 
    12971358static inline void velocity_rx_csum(struct rx_desc *rd, struct sk_buff *skb) 
    12981359{ 
     1360        u8 bCSM; 
     1361        HAIL("velocity_rx_csum"); 
    12991362        skb->ip_summed = CHECKSUM_NONE; 
    13001363 
    1301         if (rd->rdesc1.CSM & CSM_IPKT) { 
    1302                 if (rd->rdesc1.CSM & CSM_IPOK) { 
    1303                         if ((rd->rdesc1.CSM & CSM_TCPKT) || 
    1304                                         (rd->rdesc1.CSM & CSM_UDPKT)) { 
    1305                                 if (!(rd->rdesc1.CSM & CSM_TUPOK)) { 
     1364//      if (rd->rdesc1.CSM & CSM_IPKT) { 
     1365//              if (rd->rdesc1.CSM & CSM_IPOK) { 
     1366//                      if ((rd->rdesc1.CSM & CSM_TCPKT) || 
     1367//                                      (rd->rdesc1.CSM & CSM_UDPKT)) { 
     1368//                              if (!(rd->rdesc1.CSM & CSM_TUPOK)) { 
     1369        bCSM = (u8)(cpu_to_le32(rd->rdesc1) >> 16); /* BE */ 
     1370        if (bCSM & CSM_IPKT) { 
     1371                if (bCSM & CSM_IPOK) { 
     1372                        if ((bCSM & CSM_TCPKT) || 
     1373                            (bCSM & CSM_UDPKT)) { 
     1374                                if (!(bCSM & CSM_TUPOK)) {      /* BE */ 
    13061375                                        return; 
    13071376                                } 
    13081377                        } 
     
    13281397{ 
    13291398        int ret = -1; 
    13301399 
     1400        HAIL("velocity_rx_copy"); 
    13311401        if (pkt_size < rx_copybreak) { 
    13321402                struct sk_buff *new_skb; 
    13331403 
     1404                HAIL("velocity_rx_copy (working...)"); 
    13341405                new_skb = dev_alloc_skb(pkt_size + 2); 
    13351406                if (new_skb) { 
    13361407                        new_skb->dev = vptr->dev; 
     
    13611432static inline void velocity_iph_realign(struct velocity_info *vptr, 
    13621433                                        struct sk_buff *skb, int pkt_size) 
    13631434{ 
     1435        HAIL("velocity_iph_realign"); 
    13641436        /* FIXME - memmove ? */ 
    13651437        if (vptr->flags & VELOCITY_FLAGS_IP_ALIGN) { 
    13661438                int i; 
    13671439 
     1440                HAIL("velocity_iph_realign (working...)"); 
    13681441                for (i = pkt_size; i >= 0; i--) 
    13691442                        *(skb->data + i + 2) = *(skb->data + i); 
    13701443                skb_reserve(skb, 2); 
     
    13831456static int velocity_receive_frame(struct velocity_info *vptr, int idx) 
    13841457{ 
    13851458        void (*pci_action)(struct pci_dev *, dma_addr_t, size_t, int); 
     1459        u16 pkt_len; /* BE */ 
     1460        u16 wRSR;    /* BE */ 
     1461        struct sk_buff *skb; 
    13861462        struct net_device_stats *stats = &vptr->stats; 
    13871463        struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]); 
    13881464        struct rx_desc *rd = &(vptr->rd_ring[idx]); 
    1389         int pkt_len = rd->rdesc0.len; 
    1390         struct sk_buff *skb; 
     1465        /* int pkt_len = rd->rdesc0.len BE */; 
     1466 
     1467        pkt_len = ((cpu_to_le32(rd->rdesc0) >> 16) & 0x00003FFFUL); /* BE */ 
     1468        wRSR = (u16)(cpu_to_le32(rd->rdesc0)); /* BE */ 
    13911469 
    1392         if (rd->rdesc0.RSR & (RSR_STP | RSR_EDP)) { 
     1470        HAIL("velocity_receive_frame"); 
     1471        /* if (rd->rdesc0.RSR & (RSR_STP | RSR_EDP)) { BE */ 
     1472        if (wRSR & (RSR_STP | RSR_EDP)) { /* BE */ 
    13931473                VELOCITY_PRT(MSG_LEVEL_VERBOSE, KERN_ERR " %s : the received frame span multple RDs.\n", vptr->dev->name); 
    13941474                stats->rx_length_errors++; 
    13951475                return -EINVAL; 
    13961476        } 
    13971477 
    1398         if (rd->rdesc0.RSR & RSR_MAR) 
     1478        /* if (rd->rdesc0.RSR & RSR_MAR) BE */ 
     1479        if (wRSR & RSR_MAR) /* BE */ 
    13991480                vptr->stats.multicast++; 
    14001481 
    14011482        skb = rd_info->skb; 
     
    14081489         */ 
    14091490 
    14101491        if (vptr->flags & VELOCITY_FLAGS_VAL_PKT_LEN) { 
    1411                 if (rd->rdesc0.RSR & RSR_RL) { 
     1492                /* if (rd->rdesc0.RSR & RSR_RL) { BE */ 
     1493                if (wRSR & RSR_RL) { /* BE */ 
    14121494                        stats->rx_length_errors++; 
    14131495                        return -EINVAL; 
    14141496                } 
     
    14521534        struct rx_desc *rd = &(vptr->rd_ring[idx]); 
    14531535        struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]); 
    14541536 
     1537        HAIL("velocity_alloc_rx_buf"); 
    14551538        rd_info->skb = dev_alloc_skb(vptr->rx_buf_sz + 64); 
    14561539        if (rd_info->skb == NULL) 
    14571540                return -ENOMEM; 
     
    14691552         */ 
    14701553 
    14711554        *((u32 *) & (rd->rdesc0)) = 0; 
    1472         rd->len = cpu_to_le32(vptr->rx_buf_sz); 
    1473         rd->inten = 1; 
     1555        /* rd->len = cpu_to_le32(vptr->rx_buf_sz);             BE */ 
     1556        /* rd->inten = 1;                                      BE */ 
    14741557        rd->pa_low = cpu_to_le32(rd_info->skb_dma); 
    1475         rd->pa_high = 0; 
     1558        /* rd->pa_high = 0;                                     BE */ 
     1559        rd->ltwo &= cpu_to_le32(0xC000FFFFUL);                  /* BE */ 
     1560        rd->ltwo |= cpu_to_le32((vptr->rx_buf_sz << 16));       /* BE */ 
     1561        rd->ltwo |= cpu_to_le32(BE_INT_ENABLE);                 /* BE */ 
     1562        rd->ltwo &= cpu_to_le32(0xFFFF0000UL);                  /* BE */ 
    14761563        return 0; 
    14771564} 
    14781565 
     
    14931580        int full = 0; 
    14941581        int idx; 
    14951582        int works = 0; 
     1583        u16 wTSR; /* BE */ 
    14961584        struct velocity_td_info *tdinfo; 
    14971585        struct net_device_stats *stats = &vptr->stats; 
    14981586 
     1587        HAILS("velocity_tx_srv", status); 
    14991588        for (qnum = 0; qnum < vptr->num_txq; qnum++) { 
    15001589                for (idx = vptr->td_tail[qnum]; vptr->td_used[qnum] > 0; 
    15011590                        idx = (idx + 1) % vptr->options.numtx) { 
     
    15061595                        td = &(vptr->td_rings[qnum][idx]); 
    15071596                        tdinfo = &(vptr->td_infos[qnum][idx]); 
    15081597 
    1509                         if (td->tdesc0.owner == OWNED_BY_NIC) 
     1598                        /* if (td->tdesc0.owner == OWNED_BY_NIC) BE */ 
     1599                        if (td->tdesc0 & cpu_to_le32(BE_OWNED_BY_NIC)) /* BE */ 
    15101600                                break; 
    15111601 
    15121602                        if ((works++ > 15)) 
    15131603                                break; 
    15141604 
    1515                         if (td->tdesc0.TSR & TSR0_TERR) { 
     1605                        wTSR = (u16)cpu_to_le32(td->tdesc0); 
     1606                        /* if (td->tdesc0.TSR & TSR0_TERR) { BE */ 
     1607                        if (wTSR & TSR0_TERR) { /* BE */ 
    15161608                                stats->tx_errors++; 
    15171609                                stats->tx_dropped++; 
    1518                                 if (td->tdesc0.TSR & TSR0_CDH) 
     1610                                /* if (td->tdesc0.TSR & TSR0_CDH) BE */ 
     1611                                if (wTSR & TSR0_CDH) /* BE */ 
    15191612                                        stats->tx_heartbeat_errors++; 
    1520                                 if (td->tdesc0.TSR & TSR0_CRS) 
     1613                                /* if (td->tdesc0.TSR & TSR0_CRS) BE */ 
     1614                                if (wTSR & TSR0_CRS) /* BE */ 
    15211615                                        stats->tx_carrier_errors++; 
    1522                                 if (td->tdesc0.TSR & TSR0_ABT) 
     1616                                /* if (td->tdesc0.TSR & TSR0_ABT) BE */ 
     1617                                if (wTSR & TSR0_ABT) /* BE */ 
    15231618                                        stats->tx_aborted_errors++; 
    1524                                 if (td->tdesc0.TSR & TSR0_OWC) 
     1619                                /* if (td->tdesc0.TSR & TSR0_OWC) BE */ 
     1620                                if (wTSR & TSR0_OWC) /* BE */ 
    15251621                                        stats->tx_window_errors++; 
    15261622                        } else { 
    15271623                                stats->tx_packets++; 
     
    16101706 
    16111707static void velocity_error(struct velocity_info *vptr, int status) 
    16121708{ 
     1709        HAILS("velocity_error", status); 
    16131710 
    16141711        if (status & ISR_TXSTLI) { 
    16151712                struct mac_regs __iomem * regs = vptr->mac_regs; 
     
    16991796        struct sk_buff *skb = tdinfo->skb; 
    17001797        int i; 
    17011798 
     1799        HAIL("velocity_free_tx_buf"); 
    17021800        /* 
    17031801         *      Don't unmap the pre-allocated tx_bufs 
    17041802         */ 
     
    19022000        struct velocity_td_info *tdinfo; 
    19032001        unsigned long flags; 
    19042002        int index; 
     2003        u32 lbufsz; /* BE */ 
    19052004 
    19062005        int pktlen = skb->len; 
    19072006 
     
    19182017        td_ptr = &(vptr->td_rings[qnum][index]); 
    19192018        tdinfo = &(vptr->td_infos[qnum][index]); 
    19202019 
    1921         td_ptr->tdesc1.TCPLS = TCPLS_NORMAL; 
    1922         td_ptr->tdesc1.TCR = TCR0_TIC; 
    1923         td_ptr->td_buf[0].queue = 0; 
     2020        td_ptr->tdesc0 = 0x00000000UL;                            /* BE */ 
     2021        td_ptr->tdesc1 = 0x00000000UL;                            /* BE */ 
     2022 
     2023        /* td_ptr->tdesc1.TCPLS = TCPLS_NORMAL;         BE */ 
     2024        td_ptr->tdesc1 &= cpu_to_le32(0xfcffffffUL);              /* BE */ 
     2025        td_ptr->tdesc1 |= cpu_to_le32(((u32)TCPLS_NORMAL) << 24); /* BE */ 
     2026 
     2027        /* td_ptr->tdesc1.TCR = TCR0_TIC;               BE */ 
     2028        td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_TIC);                /* BE */ 
     2029 
     2030        /*      td_ptr->td_buf[0].queue = 0;            BE */ 
     2031        td_ptr->td_buf[0].ltwo &= cpu_to_le32(~BE_QUEUE_ENABLE);  /* BE */ 
    19242032 
    19252033        /* 
    19262034         *      Pad short frames. 
     
    19322040                memset(tdinfo->buf + skb->len, 0, ETH_ZLEN - skb->len); 
    19332041                tdinfo->skb = skb; 
    19342042                tdinfo->skb_dma[0] = tdinfo->buf_dma; 
    1935                 td_ptr->tdesc0.pktsize = pktlen; 
     2043                /* td_ptr->tdesc0.pktsize = pktlen; */ 
     2044                td_ptr->tdesc0 &= cpu_to_le32(0xc000ffffUL); /* BE */ 
     2045                lbufsz = pktlen; /* Assign, and make sure it's unsigned 32 bits - BE */ 
     2046                lbufsz = lbufsz << 16; /* BE - shift over     */ 
     2047                td_ptr->tdesc0 |= cpu_to_le32(lbufsz); /* BE */ 
     2048 
    19362049                td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]); 
    1937                 td_ptr->td_buf[0].pa_high = 0; 
    1938                 td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize; 
     2050                /* td_ptr->td_buf[0].pa_high = 0; */ 
     2051                /* td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize; */ 
     2052                td_ptr->td_buf[0].ltwo = cpu_to_le32(lbufsz);   /* BE */ 
    19392053                tdinfo->nskb_dma = 1; 
    1940                 td_ptr->tdesc1.CMDZ = 2; 
     2054                /* td_ptr->tdesc1.CMDZ = 2; */ 
     2055                td_ptr->tdesc1 &= cpu_to_le32(0x0fffffffUL); /* BE */ 
     2056                td_ptr->tdesc1 |= cpu_to_le32(((u32)0x2) << 28); /* BE */ 
    19412057        } else 
    19422058#ifdef VELOCITY_ZERO_COPY_SUPPORT 
     2059        /* 
     2060         * BE - NOTE on the VELOCITY_ZERO_COPY_SUPPORT: 
     2061         * This block of code has NOT been patched up for BE support, as 
     2062         * it is certainly broken -- if it compiles at all.  Since the BE 
     2063         * fixes depend on the broken code, attempts to convert to BE support 
     2064         * would almost certainly confuse more than help. 
     2065         */ 
    19432066        if (skb_shinfo(skb)->nr_frags > 0) { 
    19442067                int nfrags = skb_shinfo(skb)->nr_frags; 
    19452068                tdinfo->skb = skb; 
    19462069                if (nfrags > 6) { 
    19472070                        skb_copy_from_linear_data(skb, tdinfo->buf, skb->len); 
    19482071                        tdinfo->skb_dma[0] = tdinfo->buf_dma; 
     2072                        /* BE: Er, exactly what value are we assigning in this next line? */ 
    19492073                        td_ptr->tdesc0.pktsize = 
    19502074                        td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]); 
    19512075                        td_ptr->td_buf[0].pa_high = 0; 
     
    19622086                        /* FIXME: support 48bit DMA later */ 
    19632087                        td_ptr->td_buf[i].pa_low = cpu_to_le32(tdinfo->skb_dma); 
    19642088                        td_ptr->td_buf[i].pa_high = 0; 
     2089                        /* BE: This next line can't be right: */ 
    19652090                        td_ptr->td_buf[i].bufsize = skb->len->skb->data_len; 
    19662091 
    19672092                        for (i = 0; i < nfrags; i++) { 
     
    19792104                } 
    19802105 
    19812106        } else 
    1982 #endif 
     2107#endif /* (broken) VELOCITY_ZERO_COPY_SUPPORT */ 
    19832108        { 
    19842109                /* 
    19852110                 *      Map the linear network buffer into PCI space and 
     
    19872112                 */ 
    19882113                tdinfo->skb = skb; 
    19892114                tdinfo->skb_dma[0] = pci_map_single(vptr->pdev, skb->data, pktlen, PCI_DMA_TODEVICE); 
    1990                 td_ptr->tdesc0.pktsize = pktlen; 
     2115                /* td_ptr->tdesc0.pktsize = pktlen;                     BE */ 
     2116                td_ptr->tdesc0 &= cpu_to_le32(0xc000ffffUL);    /* BE */ 
     2117                lbufsz = pktlen; /* Assign, and make sure it's unsigned 32 bits - BE */ 
     2118                lbufsz = lbufsz << 16;                          /* BE */ 
     2119                td_ptr->tdesc0 |= cpu_to_le32(lbufsz);          /* BE */ 
    19912120                td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]); 
    1992                 td_ptr->td_buf[0].pa_high = 0; 
    1993                 td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize; 
     2121                /* td_ptr->td_buf[0].pa_high = 0;                       BE */ 
     2122                /* td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize;  BE */ 
     2123                td_ptr->td_buf[0].ltwo = cpu_to_le32(lbufsz);   /* BE */ 
     2124 
    19942125                tdinfo->nskb_dma = 1; 
    1995                 td_ptr->tdesc1.CMDZ = 2; 
     2126                /* td_ptr->tdesc1.CMDZ = 2;                             BE */ 
     2127                td_ptr->tdesc1 &= cpu_to_le32(0x0fffffffUL);    /* BE */ 
     2128                td_ptr->tdesc1 |= cpu_to_le32(((u32)0x2) << 28);/* BE */ 
    19962129        } 
    19972130 
    19982131        if (vptr->flags & VELOCITY_FLAGS_TAGGING) { 
    1999                 td_ptr->tdesc1.pqinf.VID = (vptr->options.vid & 0xfff); 
    2000                 td_ptr->tdesc1.pqinf.priority = 0; 
    2001                 td_ptr->tdesc1.pqinf.CFI = 0; 
    2002                 td_ptr->tdesc1.TCR |= TCR0_VETAG; 
     2132                /* td_ptr->tdesc1.pqinf.priority = 0;                   BE */ 
     2133                /* td_ptr->tdesc1.pqinf.CFI = 0;                        BE */ 
     2134                td_ptr->tdesc1 &= cpu_to_le32(0xFFFF0000UL);    /* BE */ 
     2135                /* td_ptr->tdesc1.pqinf.VID = (vptr->options.vid & 0xfff); BE */ 
     2136                td_ptr->tdesc1 |= cpu_to_le32((vptr->options.vid & 0xfff)); /* BE */ 
     2137                /* td_ptr->tdesc1.TCR |= TCR0_VETAG;                    BE */ 
     2138                td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_VETAG);    /* BE */ 
    20032139        } 
    20042140 
    20052141        /* 
     
    20092145                                 && (skb->ip_summed == CHECKSUM_PARTIAL)) { 
    20102146                const struct iphdr *ip = ip_hdr(skb); 
    20112147                if (ip->protocol == IPPROTO_TCP) 
    2012                         td_ptr->tdesc1.TCR |= TCR0_TCPCK; 
     2148                        /* td_ptr->tdesc1.TCR |= TCR0_TCPCK;    BE */ 
     2149                        td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_TCPCK);    /* BE */ 
    20132150                else if (ip->protocol == IPPROTO_UDP) 
    2014                         td_ptr->tdesc1.TCR |= (TCR0_UDPCK); 
    2015                 td_ptr->tdesc1.TCR |= TCR0_IPCK; 
    2016         } 
     2151                        /* td_ptr->tdesc1.TCR |= (TCR0_UDPCK);  BE */ 
     2152                        td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_UDPCK);    /* BE */ 
     2153                /* td_ptr->tdesc1.TCR |= TCR0_IPCK;             BE */ 
     2154                td_ptr->tdesc1 |= cpu_to_le32(BE_TCR_IPCK);             /* BE */ 
     2155        } 
    20172156        { 
    20182157 
    20192158                int prev = index - 1; 
    20202159 
    20212160                if (prev < 0) 
    20222161                        prev = vptr->options.numtx - 1; 
    2023                 td_ptr->tdesc0.owner = OWNED_BY_NIC; 
     2162                /* td_ptr->tdesc0.owner = OWNED_BY_NIC; BE */ 
     2163                td_ptr->tdesc0 |= cpu_to_le32(BE_OWNED_BY_NIC); /* BE */ 
    20242164                vptr->td_used[qnum]++; 
    20252165                vptr->td_curr[qnum] = (index + 1) % vptr->options.numtx; 
    20262166 
    20272167                if (AVAIL_TD(vptr, qnum) < 1) 
    20282168                        netif_stop_queue(dev); 
    20292169 
    2030                 td_ptr = &(vptr->td_rings[qnum][prev]); 
    2031                 td_ptr->td_buf[0].queue = 1; 
     2170                td_ptr = &(vptr->td_rings[qnum][prev]); 
     2171                /* td_ptr->td_buf[0].queue = 1; BE */ 
     2172                td_ptr->td_buf[0].ltwo |= cpu_to_le32(BE_QUEUE_ENABLE); /* BE */ 
     2173                if (vdebug&2) printk(KERN_NOTICE "velocity_xmit: (%s) len=%d idx=%d tdesc0=0x%x tdesc1=0x%x ltwo=0x%x\n", 
     2174                        (pktlen<ETH_ZLEN) ? "short" : "normal", pktlen, index, 
     2175                        td_ptr->tdesc0, td_ptr->tdesc1, td_ptr->td_buf[0].ltwo); 
    20322176                mac_tx_queue_wake(vptr->mac_regs, qnum); 
    20332177        } 
    20342178        dev->trans_start = jiffies; 
     
    20542198        u32 isr_status; 
    20552199        int max_count = 0; 
    20562200 
    2057  
     2201        HAIL("velocity_intr"); 
    20582202        spin_lock(&vptr->lock); 
    20592203        isr_status = mac_read_isr(vptr->mac_regs); 
    20602204 
     
    20732217 
    20742218        while (isr_status != 0) { 
    20752219                mac_write_isr(vptr->mac_regs, isr_status); 
    2076                 if (isr_status & (~(ISR_PRXI | ISR_PPRXI | ISR_PTXI | ISR_PPTXI))) 
     2220                HAILS("velocity_intr",isr_status); 
     2221                /* MJW - velocity_error is ALWAYS called; need to mask off some other flags */ 
     2222                /* if (isr_status & (~(ISR_PRXI | ISR_PPRXI | ISR_PTXI | ISR_PPTXI))) */ 
     2223                if (isr_status & (~(ISR_PRXI | ISR_PPRXI | ISR_PTXI | ISR_PPTXI | ISR_PTX0I | ISR_ISR0))) 
    20772224                        velocity_error(vptr, isr_status); 
    20782225                if (isr_status & (ISR_PRXI | ISR_PPRXI)) 
    20792226                        max_count += velocity_rx_srv(vptr, isr_status); 
     
    21112258        int i; 
    21122259        struct dev_mc_list *mclist; 
    21132260 
     2261        HAIL("velocity_set_multi"); 
    21142262        if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */ 
    21152263                writel(0xffffffff, &regs->MARCAM[0]); 
    21162264                writel(0xffffffff, &regs->MARCAM[4]); 
     
    21542302{ 
    21552303        struct velocity_info *vptr = netdev_priv(dev); 
    21562304 
     2305        HAIL("net_device_stats"); 
    21572306        /* If the hardware is down, don't touch MII */ 
    21582307        if(!netif_running(dev)) 
    21592308                return &vptr->stats; 
     
    21982347        struct velocity_info *vptr = netdev_priv(dev); 
    21992348        int ret; 
    22002349 
     2350        HAIL("velocity_ioctl"); 
    22012351        /* If we are asked for information and the device is power 
    22022352           saving then we need to bring the device back up to talk to it */ 
    22032353 
     
    24162566{ 
    24172567        u16 ww; 
    24182568 
     2569        HAIL("velocity_mii_read"); 
    24192570        /* 
    24202571         *      Disable MIICR_MAUTO, so that mii addr can be set normally 
    24212572         */ 
     
    24522603{ 
    24532604        u16 ww; 
    24542605 
     2606        HAIL("velocity_mii_write"); 
    24552607        /* 
    24562608         *      Disable MIICR_MAUTO, so that mii addr can be set normally 
    24572609         */ 
  • linux-2.6.22-rc1-arm/drivers/net/via-velocity.h

    old new  
    196196 *      Receive descriptor 
    197197 */ 
    198198 
    199 struct rdesc0 { 
    200       u16 RSR;                /* Receive status */ 
    201       u16 len:14;             /* Received packet length */ 
    202       u16 reserved:1; 
    203       u16 owner:1;            /* Who owns this buffer ? */ 
    204 }; 
    205  
    206 struct rdesc1 { 
    207       u16 PQTAG; 
    208       u8 CSM; 
    209       u8 IPKT; 
    210 }; 
     199//struct rdesc0 { 
     200//    u16 RSR;                /* Receive status */ 
     201//    u16 len:14;             /* Received packet length */ 
     202//    u16 reserved:1; 
     203//    u16 owner:1;            /* Who owns this buffer ? */ 
     204//}; 
     205 
     206//struct rdesc1 { 
     207//    u16 PQTAG; 
     208//    u8 CSM; 
     209//    u8 IPKT; 
     210//}; 
    211211 
    212212struct rx_desc { 
    213         struct rdesc0 rdesc0; 
    214         struct rdesc1 rdesc1; 
     213//      struct rdesc0 rdesc0; 
     214//      struct rdesc1 rdesc1; 
     215        u32 rdesc0; 
     216        u32 rdesc1; 
    215217        u32 pa_low;             /* Low 32 bit PCI address */ 
    216         u16 pa_high;            /* Next 16 bit PCI address (48 total) */ 
    217         u16 len:15;             /* Frame size */ 
    218         u16 inten:1;            /* Enable interrupt */ 
     218//      u16 pa_high;            /* Next 16 bit PCI address (48 total) */ 
     219//      u16 len:15;             /* Frame size */ 
     220//      u16 inten:1;            /* Enable interrupt */ 
     221        u32 ltwo; 
    219222} __attribute__ ((__packed__)); 
    220223 
    221224/* 
    222225 *      Transmit descriptor 
    223226 */ 
    224227 
    225 struct tdesc0 { 
    226       u16 TSR;                /* Transmit status register */ 
    227       u16 pktsize:14;         /* Size of frame */ 
    228       u16 reserved:1; 
    229       u16 owner:1;            /* Who owns the buffer */ 
    230 }; 
    231  
    232 struct pqinf {                        /* Priority queue info */ 
    233       u16 VID:12; 
    234       u16 CFI:1; 
    235       u16 priority:3; 
    236 } __attribute__ ((__packed__)); 
    237  
    238 struct tdesc1 { 
    239       struct pqinf pqinf; 
    240       u8 TCR; 
    241       u8 TCPLS:2; 
    242       u8 reserved:2; 
    243       u8 CMDZ:4; 
    244 } __attribute__ ((__packed__)); 
     228//struct tdesc0 { 
     229//    u16 TSR;                /* Transmit status register */ 
     230//    u16 pktsize:14;         /* Size of frame */ 
     231//    u16 reserved:1; 
     232//    u16 owner:1;            /* Who owns the buffer */ 
     233//}; 
     234 
     235//struct pqinf {                      /* Priority queue info */ 
     236//    u16 VID:12; 
     237//    u16 CFI:1; 
     238//    u16 priority:3; 
     239//} __attribute__ ((__packed__)); 
     240 
     241//struct tdesc1 { 
     242//    struct pqinf pqinf; 
     243//    u8 TCR; 
     244//    u8 TCPLS:2; 
     245//    u8 reserved:2; 
     246//    u8 CMDZ:4; 
     247//} __attribute__ ((__packed__)); 
    245248 
    246249struct td_buf { 
    247250        u32 pa_low; 
    248         u16 pa_high; 
    249         u16 bufsize:14; 
    250         u16 reserved:1; 
    251         u16 queue:1; 
     251//      u16 pa_high; 
     252//      u16 bufsize:14; 
     253//      u16 reserved:1; 
     254//      u16 queue:1; 
     255        u32 ltwo; 
    252256} __attribute__ ((__packed__)); 
    253257 
    254258struct tx_desc { 
    255         struct tdesc0 tdesc0; 
    256         struct tdesc1 tdesc1; 
     259//      struct tdesc0 tdesc0; 
     260//      struct tdesc1 tdesc1; 
     261        u32 tdesc0; 
     262        u32 tdesc1; 
    257263        struct td_buf td_buf[7]; 
    258264}; 
    259265 
     
    279285        OWNED_BY_NIC = 1 
    280286}; 
    281287 
     288/* Constants added for the BE fixes */ 
     289#define BE_OWNED_BY_NIC    0x80000000UL 
     290#define BE_INT_ENABLE      0x80000000UL 
     291#define BE_QUEUE_ENABLE    0x80000000UL 
     292#define BE_TCR_TIC         0x00800000UL 
     293#define BE_TCR_VETAG       0x00200000UL 
     294#define BE_TCR_TCPCK       0x00040000UL 
     295#define BE_TCR_UDPCK       0x00080000UL 
     296#define BE_TCR_IPCK        0x00100000UL 
     297 
    282298 
    283299/* 
    284300 *      MAC registers and macros. 
     
    16981714}; 
    16991715 
    17001716struct velocity_opt { 
     1717        int velo_debug;                 /* debug flag */ 
    17011718        int numrx;                      /* Number of RX descriptors */ 
    17021719        int numtx;                      /* Number of TX descriptors */ 
    17031720        enum speed_opt spd_dpx;         /* Media link mode */ 
Note: See TracBrowser for help on using the browser.