X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;f=drivers%2Fstaging%2Fvt6655%2Fdevice_main.c;h=fcc4510f81b35450e846a18bca81f87fcf956af6;hb=73eb8a11275ecadf7f49ffc1e67f7cef35188182;hp=0d8f123c57fe22cebe800d7c282e6808bb046b3c;hpb=77a78806c7df8d414c33031a1ca5121876910c4f;p=karo-tx-linux.git diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 0d8f123c57fe..fcc4510f81b3 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -128,14 +128,8 @@ DEVICE_PARAM(BasebandType, "baseband type"); /* * Static vars definitions */ -static CHIP_INFO chip_info_table[] = { - { VT3253, "VIA Networking Solomon-A/B/G Wireless LAN Adapter ", - 256, 1, DEVICE_FLAGS_IP_ALIGN|DEVICE_FLAGS_TX_ALIGN }, - {0, NULL} -}; - static const struct pci_device_id vt6655_pci_id_table[] = { - { PCI_VDEVICE(VIA, 0x3253), (kernel_ulong_t)chip_info_table}, + { PCI_VDEVICE(VIA, 0x3253) }, { 0, } }; @@ -143,7 +137,7 @@ static const struct pci_device_id vt6655_pci_id_table[] = { static int vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent); static void vt6655_init_info(struct pci_dev *pcid, - struct vnt_private **ppDevice, PCHIP_INFO); + struct vnt_private **ppDevice); static void device_free_info(struct vnt_private *pDevice); static bool device_get_pci_info(struct vnt_private *, struct pci_dev *pcid); static void device_print_info(struct vnt_private *pDevice); @@ -155,7 +149,7 @@ static void device_init_td1_ring(struct vnt_private *pDevice); static int device_rx_srv(struct vnt_private *pDevice, unsigned int uIdx); static int device_tx_srv(struct vnt_private *pDevice, unsigned int uIdx); -static bool device_alloc_rx_buf(struct vnt_private *pDevice, PSRxDesc pDesc); +static bool device_alloc_rx_buf(struct vnt_private *, struct vnt_rx_desc *); static void device_init_registers(struct vnt_private *pDevice); static void device_free_tx_buf(struct vnt_private *, struct vnt_tx_desc *); static void device_free_td0_ring(struct vnt_private *pDevice); @@ -168,16 +162,6 @@ static void device_free_rings(struct vnt_private *pDevice); /*--------------------- Export Functions --------------------------*/ -static char *get_chip_name(int chip_id) -{ - int i; - - for (i = 0; chip_info_table[i].name != NULL; i++) - if (chip_info_table[i].chip_id == chip_id) - break; - return chip_info_table[i].name; -} - static void vt6655_remove(struct pci_dev *pcid) { struct vnt_private *pDevice = pci_get_drvdata(pcid); @@ -447,24 +431,17 @@ static void device_init_registers(struct vnt_private *pDevice) static void device_print_info(struct vnt_private *pDevice) { - dev_info(&pDevice->pcid->dev, "%s\n", get_chip_name(pDevice->chip_id)); - dev_info(&pDevice->pcid->dev, "MAC=%pM IO=0x%lx Mem=0x%lx IRQ=%d\n", pDevice->abyCurrentNetAddr, (unsigned long)pDevice->ioaddr, (unsigned long)pDevice->PortOffset, pDevice->pcid->irq); } static void vt6655_init_info(struct pci_dev *pcid, - struct vnt_private **ppDevice, - PCHIP_INFO pChip_info) + struct vnt_private **ppDevice) { memset(*ppDevice, 0, sizeof(**ppDevice)); (*ppDevice)->pcid = pcid; - (*ppDevice)->chip_id = pChip_info->chip_id; - (*ppDevice)->io_size = pChip_info->io_size; - (*ppDevice)->nTxQueues = pChip_info->nTxQueue; - (*ppDevice)->multicast_limit = 32; spin_lock_init(&((*ppDevice)->lock)); } @@ -520,8 +497,8 @@ static bool device_init_rings(struct vnt_private *pDevice) /*allocate all RD/TD rings a single pool*/ vir_pool = dma_zalloc_coherent(&pDevice->pcid->dev, - pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc) + - pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc) + + pDevice->sOpts.nRxDescs0 * sizeof(struct vnt_rx_desc) + + pDevice->sOpts.nRxDescs1 * sizeof(struct vnt_rx_desc) + pDevice->sOpts.nTxDescs[0] * sizeof(struct vnt_tx_desc) + pDevice->sOpts.nTxDescs[1] * sizeof(struct vnt_tx_desc), &pDevice->pool_dma, GFP_ATOMIC); @@ -532,11 +509,11 @@ static bool device_init_rings(struct vnt_private *pDevice) pDevice->aRD0Ring = vir_pool; pDevice->aRD1Ring = vir_pool + - pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc); + pDevice->sOpts.nRxDescs0 * sizeof(struct vnt_rx_desc); pDevice->rd0_pool_dma = pDevice->pool_dma; pDevice->rd1_pool_dma = pDevice->rd0_pool_dma + - pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc); + pDevice->sOpts.nRxDescs0 * sizeof(struct vnt_rx_desc); pDevice->tx0_bufs = dma_zalloc_coherent(&pDevice->pcid->dev, pDevice->sOpts.nTxDescs[0] * PKT_BUF_SZ + @@ -549,8 +526,8 @@ static bool device_init_rings(struct vnt_private *pDevice) dev_err(&pDevice->pcid->dev, "allocate buf dma memory failed\n"); dma_free_coherent(&pDevice->pcid->dev, - pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc) + - pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc) + + pDevice->sOpts.nRxDescs0 * sizeof(struct vnt_rx_desc) + + pDevice->sOpts.nRxDescs1 * sizeof(struct vnt_rx_desc) + pDevice->sOpts.nTxDescs[0] * sizeof(struct vnt_tx_desc) + pDevice->sOpts.nTxDescs[1] * sizeof(struct vnt_tx_desc), vir_pool, pDevice->pool_dma @@ -559,19 +536,19 @@ static bool device_init_rings(struct vnt_private *pDevice) } pDevice->td0_pool_dma = pDevice->rd1_pool_dma + - pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc); + pDevice->sOpts.nRxDescs1 * sizeof(struct vnt_rx_desc); pDevice->td1_pool_dma = pDevice->td0_pool_dma + pDevice->sOpts.nTxDescs[0] * sizeof(struct vnt_tx_desc); /* vir_pool: pvoid type */ pDevice->apTD0Rings = vir_pool - + pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc) - + pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc); + + pDevice->sOpts.nRxDescs0 * sizeof(struct vnt_rx_desc) + + pDevice->sOpts.nRxDescs1 * sizeof(struct vnt_rx_desc); pDevice->apTD1Rings = vir_pool - + pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc) - + pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc) + + pDevice->sOpts.nRxDescs0 * sizeof(struct vnt_rx_desc) + + pDevice->sOpts.nRxDescs1 * sizeof(struct vnt_rx_desc) + pDevice->sOpts.nTxDescs[0] * sizeof(struct vnt_tx_desc); pDevice->tx1_bufs = pDevice->tx0_bufs + @@ -595,8 +572,8 @@ static bool device_init_rings(struct vnt_private *pDevice) static void device_free_rings(struct vnt_private *pDevice) { dma_free_coherent(&pDevice->pcid->dev, - pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc) + - pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc) + + pDevice->sOpts.nRxDescs0 * sizeof(struct vnt_rx_desc) + + pDevice->sOpts.nRxDescs1 * sizeof(struct vnt_rx_desc) + pDevice->sOpts.nTxDescs[0] * sizeof(struct vnt_tx_desc) + pDevice->sOpts.nTxDescs[1] * sizeof(struct vnt_tx_desc) , @@ -617,18 +594,19 @@ static void device_init_rd0_ring(struct vnt_private *pDevice) { int i; dma_addr_t curr = pDevice->rd0_pool_dma; - PSRxDesc pDesc; + struct vnt_rx_desc *pDesc; /* Init the RD0 ring entries */ - for (i = 0; i < pDevice->sOpts.nRxDescs0; i ++, curr += sizeof(SRxDesc)) { + for (i = 0; i < pDevice->sOpts.nRxDescs0; + i ++, curr += sizeof(struct vnt_rx_desc)) { pDesc = &(pDevice->aRD0Ring[i]); - pDesc->pRDInfo = alloc_rd_info(); + pDesc->rd_info = alloc_rd_info(); if (!device_alloc_rx_buf(pDevice, pDesc)) dev_err(&pDevice->pcid->dev, "can not alloc rx bufs\n"); pDesc->next = &(pDevice->aRD0Ring[(i+1) % pDevice->sOpts.nRxDescs0]); - pDesc->next_desc = cpu_to_le32(curr + sizeof(SRxDesc)); + pDesc->next_desc = cpu_to_le32(curr + sizeof(struct vnt_rx_desc)); } if (i > 0) @@ -640,18 +618,19 @@ static void device_init_rd1_ring(struct vnt_private *pDevice) { int i; dma_addr_t curr = pDevice->rd1_pool_dma; - PSRxDesc pDesc; + struct vnt_rx_desc *pDesc; /* Init the RD1 ring entries */ - for (i = 0; i < pDevice->sOpts.nRxDescs1; i ++, curr += sizeof(SRxDesc)) { + for (i = 0; i < pDevice->sOpts.nRxDescs1; + i ++, curr += sizeof(struct vnt_rx_desc)) { pDesc = &(pDevice->aRD1Ring[i]); - pDesc->pRDInfo = alloc_rd_info(); + pDesc->rd_info = alloc_rd_info(); if (!device_alloc_rx_buf(pDevice, pDesc)) dev_err(&pDevice->pcid->dev, "can not alloc rx bufs\n"); pDesc->next = &(pDevice->aRD1Ring[(i+1) % pDevice->sOpts.nRxDescs1]); - pDesc->next_desc = cpu_to_le32(curr + sizeof(SRxDesc)); + pDesc->next_desc = cpu_to_le32(curr + sizeof(struct vnt_rx_desc)); } if (i > 0) @@ -664,15 +643,15 @@ static void device_free_rd0_ring(struct vnt_private *pDevice) int i; for (i = 0; i < pDevice->sOpts.nRxDescs0; i++) { - PSRxDesc pDesc = &(pDevice->aRD0Ring[i]); - PDEVICE_RD_INFO pRDInfo = pDesc->pRDInfo; + struct vnt_rx_desc *pDesc = &(pDevice->aRD0Ring[i]); + struct vnt_rd_info *rd_info = pDesc->rd_info; - dma_unmap_single(&pDevice->pcid->dev, pRDInfo->skb_dma, + dma_unmap_single(&pDevice->pcid->dev, rd_info->skb_dma, pDevice->rx_buf_sz, DMA_FROM_DEVICE); - dev_kfree_skb(pRDInfo->skb); + dev_kfree_skb(rd_info->skb); - kfree(pDesc->pRDInfo); + kfree(pDesc->rd_info); } } @@ -681,15 +660,15 @@ static void device_free_rd1_ring(struct vnt_private *pDevice) int i; for (i = 0; i < pDevice->sOpts.nRxDescs1; i++) { - PSRxDesc pDesc = &(pDevice->aRD1Ring[i]); - PDEVICE_RD_INFO pRDInfo = pDesc->pRDInfo; + struct vnt_rx_desc *pDesc = &(pDevice->aRD1Ring[i]); + struct vnt_rd_info *rd_info = pDesc->rd_info; - dma_unmap_single(&pDevice->pcid->dev, pRDInfo->skb_dma, + dma_unmap_single(&pDevice->pcid->dev, rd_info->skb_dma, pDevice->rx_buf_sz, DMA_FROM_DEVICE); - dev_kfree_skb(pRDInfo->skb); + dev_kfree_skb(rd_info->skb); - kfree(pDesc->pRDInfo); + kfree(pDesc->rd_info); } } @@ -705,10 +684,9 @@ static void device_init_td0_ring(struct vnt_private *pDevice) pDesc = &(pDevice->apTD0Rings[i]); pDesc->td_info = alloc_td_info(); - if (pDevice->flags & DEVICE_FLAGS_TX_ALIGN) { - pDesc->td_info->buf = pDevice->tx0_bufs + (i)*PKT_BUF_SZ; - pDesc->td_info->buf_dma = pDevice->tx_bufs_dma0 + (i)*PKT_BUF_SZ; - } + pDesc->td_info->buf = pDevice->tx0_bufs + i * PKT_BUF_SZ; + pDesc->td_info->buf_dma = pDevice->tx_bufs_dma0 + i * PKT_BUF_SZ; + pDesc->next = &(pDevice->apTD0Rings[(i+1) % pDevice->sOpts.nTxDescs[0]]); pDesc->next_desc = cpu_to_le32(curr + sizeof(struct vnt_tx_desc)); } @@ -731,10 +709,9 @@ static void device_init_td1_ring(struct vnt_private *pDevice) pDesc = &(pDevice->apTD1Rings[i]); pDesc->td_info = alloc_td_info(); - if (pDevice->flags & DEVICE_FLAGS_TX_ALIGN) { - pDesc->td_info->buf = pDevice->tx1_bufs + (i) * PKT_BUF_SZ; - pDesc->td_info->buf_dma = pDevice->tx_bufs_dma1 + (i) * PKT_BUF_SZ; - } + pDesc->td_info->buf = pDevice->tx1_bufs + i * PKT_BUF_SZ; + pDesc->td_info->buf_dma = pDevice->tx_bufs_dma1 + i * PKT_BUF_SZ; + pDesc->next = &(pDevice->apTD1Rings[(i + 1) % pDevice->sOpts.nTxDescs[1]]); pDesc->next_desc = cpu_to_le32(curr + sizeof(struct vnt_tx_desc)); } @@ -774,16 +751,16 @@ static void device_free_td1_ring(struct vnt_private *pDevice) static int device_rx_srv(struct vnt_private *pDevice, unsigned int uIdx) { - PSRxDesc pRD; + struct vnt_rx_desc *pRD; int works = 0; for (pRD = pDevice->pCurrRD[uIdx]; - pRD->m_rd0RD0.f1Owner == OWNED_BY_HOST; + pRD->rd0.owner == OWNED_BY_HOST; pRD = pRD->next) { if (works++ > 15) break; - if (!pRD->pRDInfo->skb) + if (!pRD->rd_info->skb) break; if (vnt_receive_frame(pDevice, pRD)) { @@ -793,7 +770,7 @@ static int device_rx_srv(struct vnt_private *pDevice, unsigned int uIdx) break; } } - pRD->m_rd0RD0.f1Owner = OWNED_BY_NIC; + pRD->rd0.owner = OWNED_BY_NIC; } pDevice->pCurrRD[uIdx] = pRD; @@ -801,9 +778,10 @@ static int device_rx_srv(struct vnt_private *pDevice, unsigned int uIdx) return works; } -static bool device_alloc_rx_buf(struct vnt_private *pDevice, PSRxDesc pRD) +static bool device_alloc_rx_buf(struct vnt_private *pDevice, + struct vnt_rx_desc *pRD) { - PDEVICE_RD_INFO pRDInfo = pRD->pRDInfo; + struct vnt_rd_info *pRDInfo = pRD->rd_info; pRDInfo->skb = dev_alloc_skb((int)pDevice->rx_buf_sz); if (pRDInfo->skb == NULL) @@ -814,11 +792,11 @@ static bool device_alloc_rx_buf(struct vnt_private *pDevice, PSRxDesc pRD) skb_put(pRDInfo->skb, skb_tailroom(pRDInfo->skb)), pDevice->rx_buf_sz, DMA_FROM_DEVICE); - *((unsigned int *)&(pRD->m_rd0RD0)) = 0; /* FIX cast */ + *((unsigned int *)&pRD->rd0) = 0; /* FIX cast */ - pRD->m_rd0RD0.wResCount = cpu_to_le16(pDevice->rx_buf_sz); - pRD->m_rd0RD0.f1Owner = OWNED_BY_NIC; - pRD->m_rd1RD1.wReqCount = cpu_to_le16(pDevice->rx_buf_sz); + pRD->rd0.res_count = cpu_to_le16(pDevice->rx_buf_sz); + pRD->rd0.owner = OWNED_BY_NIC; + pRD->rd1.req_count = cpu_to_le16(pDevice->rx_buf_sz); pRD->buff_addr = cpu_to_le32(pRDInfo->skb_dma); return true; @@ -1649,7 +1627,6 @@ static int vnt_init(struct vnt_private *priv) static int vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) { - PCHIP_INFO pChip_info = (PCHIP_INFO)ent->driver_data; struct vnt_private *priv; struct ieee80211_hw *hw; struct wiphy *wiphy; @@ -1669,7 +1646,7 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) priv = hw->priv; - vt6655_init_info(pcid, &priv, pChip_info); + vt6655_init_info(pcid, &priv); priv->hw = hw; @@ -1689,54 +1666,8 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) return -ENODEV; } -#ifdef DEBUG - dev_dbg(&pcid->dev, - "after get pci_info memaddr is %x, io addr is %x,io_size is %d\n", - priv->memaddr, priv->ioaddr, priv->io_size); - { - int i; - u32 bar, len; - u32 address[] = { - PCI_BASE_ADDRESS_0, - PCI_BASE_ADDRESS_1, - PCI_BASE_ADDRESS_2, - PCI_BASE_ADDRESS_3, - PCI_BASE_ADDRESS_4, - PCI_BASE_ADDRESS_5, - 0}; - for (i = 0; address[i]; i++) { - pci_read_config_dword(pcid, address[i], &bar); - - dev_dbg(&pcid->dev, "bar %d is %x\n", i, bar); - - if (!bar) { - dev_dbg(&pcid->dev, - "bar %d not implemented\n", i); - continue; - } - - if (bar & PCI_BASE_ADDRESS_SPACE_IO) { - /* This is IO */ - - len = bar & (PCI_BASE_ADDRESS_IO_MASK & 0xffff); - len = len & ~(len - 1); - - dev_dbg(&pcid->dev, - "IO space: len in IO %x, BAR %d\n", - len, i); - } else { - len = bar & 0xfffffff0; - len = ~len + 1; - - dev_dbg(&pcid->dev, - "len in MEM %x, BAR %d\n", len, i); - } - } - } -#endif - priv->PortOffset = ioremap(priv->memaddr & PCI_BASE_ADDRESS_MEM_MASK, - priv->io_size); + 256); if (!priv->PortOffset) { dev_err(&pcid->dev, ": Failed to IO remapping ..\n"); device_free_info(priv); @@ -1776,11 +1707,6 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) device_get_options(priv); device_set_options(priv); - /* Mask out the options cannot be set to the chip */ - priv->sOpts.flags &= pChip_info->flags; - - /* Enable the chip specified capabilities */ - priv->flags = priv->sOpts.flags | (pChip_info->flags & 0xff000000UL); wiphy = priv->hw->wiphy;