/*
* 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, }
};
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);
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);
/*--------------------- 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);
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));
}
/*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);
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 +
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
}
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 +
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)
,
{
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)
{
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)
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);
}
}
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);
}
}
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));
}
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));
}
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];
if (works++ > 15)
break;
- if (!pRD->pRDInfo->skb)
+ if (!pRD->rd_info->skb)
break;
if (vnt_receive_frame(pDevice, pRD)) {
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)
pRD->rd0.res_count = cpu_to_le16(pDevice->rx_buf_sz);
pRD->rd0.owner = OWNED_BY_NIC;
- pRD->m_rd1RD1.wReqCount = cpu_to_le16(pDevice->rx_buf_sz);
+ pRD->rd1.req_count = cpu_to_le16(pDevice->rx_buf_sz);
pRD->buff_addr = cpu_to_le32(pRDInfo->skb_dma);
return true;
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;
priv = hw->priv;
- vt6655_init_info(pcid, &priv, pChip_info);
+ vt6655_init_info(pcid, &priv);
priv->hw = hw;
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);
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;