static void slic_link_upr_complete(struct adapter *adapter, u32 isr)
{
- u32 linkstatus = adapter->pshmem->linkstatus;
+ struct slic_shmemory *sm = &adapter->shmem;
+ struct slic_shmem_data *sm_data = sm->shmem_data;
+ u32 lst = sm_data->lnkstatus;
uint linkup;
unsigned char linkspeed;
unsigned char linkduplex;
if ((isr & ISR_UPCERR) || (isr & ISR_UPCBSY)) {
- struct slic_shmem *pshmem;
+ dma_addr_t phaddr = sm->lnkstatus_phaddr;
- pshmem = (struct slic_shmem *)(unsigned long)
- adapter->phys_shmem;
-#if BITS_PER_LONG == 64
- slic_upr_queue_request(adapter,
- SLIC_UPR_RLSR,
- SLIC_GET_ADDR_LOW(&pshmem->linkstatus),
- SLIC_GET_ADDR_HIGH(&pshmem->linkstatus),
+ slic_upr_queue_request(adapter, SLIC_UPR_RLSR,
+ cpu_to_le32(lower_32_bits(phaddr)),
+ cpu_to_le32(upper_32_bits(phaddr)),
0, 0);
-#else
- slic_upr_queue_request(adapter,
- SLIC_UPR_RLSR,
- (u32)&pshmem->linkstatus,
- SLIC_GET_ADDR_HIGH(pshmem), 0, 0);
-#endif
return;
}
if (adapter->state != ADAPT_UP)
return;
- linkup = linkstatus & GIG_LINKUP ? LINK_UP : LINK_DOWN;
- if (linkstatus & GIG_SPEED_1000)
+ linkup = lst & GIG_LINKUP ? LINK_UP : LINK_DOWN;
+ if (lst & GIG_SPEED_1000)
linkspeed = LINK_1000MB;
- else if (linkstatus & GIG_SPEED_100)
+ else if (lst & GIG_SPEED_100)
linkspeed = LINK_100MB;
else
linkspeed = LINK_10MB;
- if (linkstatus & GIG_FULLDUPLEX)
+ if (lst & GIG_FULLDUPLEX)
linkduplex = LINK_FULLD;
else
linkduplex = LINK_HALFD;
upr->next = NULL;
adapter->upr_busy = 0;
switch (upr->upr_request) {
- case SLIC_UPR_STATS:
- {
- struct slic_stats *slicstats =
- (struct slic_stats *)&adapter->pshmem->inicstats;
- struct slic_stats *newstats = slicstats;
- struct slic_stats *old = &adapter->inicstats_prev;
- struct slicnet_stats *stst = &adapter->slic_stats;
-
- if (isr & ISR_UPCERR) {
- dev_err(&adapter->netdev->dev,
- "SLIC_UPR_STATS command failed isr[%x]\n",
- isr);
-
- break;
- }
- UPDATE_STATS_GB(stst->tcp.xmit_tcp_segs,
- newstats->xmit_tcp_segs_gb,
- old->xmit_tcp_segs_gb);
-
- UPDATE_STATS_GB(stst->tcp.xmit_tcp_bytes,
- newstats->xmit_tcp_bytes_gb,
- old->xmit_tcp_bytes_gb);
-
- UPDATE_STATS_GB(stst->tcp.rcv_tcp_segs,
- newstats->rcv_tcp_segs_gb,
- old->rcv_tcp_segs_gb);
-
- UPDATE_STATS_GB(stst->tcp.rcv_tcp_bytes,
- newstats->rcv_tcp_bytes_gb,
- old->rcv_tcp_bytes_gb);
-
- UPDATE_STATS_GB(stst->iface.xmt_bytes,
- newstats->xmit_bytes_gb,
- old->xmit_bytes_gb);
-
- UPDATE_STATS_GB(stst->iface.xmt_ucast,
- newstats->xmit_unicasts_gb,
- old->xmit_unicasts_gb);
-
- UPDATE_STATS_GB(stst->iface.rcv_bytes,
- newstats->rcv_bytes_gb,
- old->rcv_bytes_gb);
-
- UPDATE_STATS_GB(stst->iface.rcv_ucast,
- newstats->rcv_unicasts_gb,
- old->rcv_unicasts_gb);
-
- UPDATE_STATS_GB(stst->iface.xmt_errors,
- newstats->xmit_collisions_gb,
- old->xmit_collisions_gb);
-
- UPDATE_STATS_GB(stst->iface.xmt_errors,
- newstats->xmit_excess_collisions_gb,
- old->xmit_excess_collisions_gb);
-
- UPDATE_STATS_GB(stst->iface.xmt_errors,
- newstats->xmit_other_error_gb,
- old->xmit_other_error_gb);
-
- UPDATE_STATS_GB(stst->iface.rcv_errors,
- newstats->rcv_other_error_gb,
- old->rcv_other_error_gb);
-
- UPDATE_STATS_GB(stst->iface.rcv_discards,
- newstats->rcv_drops_gb,
- old->rcv_drops_gb);
-
- if (newstats->rcv_drops_gb > old->rcv_drops_gb) {
- adapter->rcv_drops +=
- (newstats->rcv_drops_gb -
- old->rcv_drops_gb);
- }
- memcpy(old, newstats, sizeof(struct slic_stats));
+ case SLIC_UPR_STATS: {
+ struct slic_shmemory *sm = &adapter->shmem;
+ struct slic_shmem_data *sm_data = sm->shmem_data;
+ struct slic_stats *stats = &sm_data->stats;
+ struct slic_stats *old = &adapter->inicstats_prev;
+ struct slicnet_stats *stst = &adapter->slic_stats;
+
+ if (isr & ISR_UPCERR) {
+ dev_err(&adapter->netdev->dev,
+ "SLIC_UPR_STATS command failed isr[%x]\n", isr);
break;
}
+
+ UPDATE_STATS_GB(stst->tcp.xmit_tcp_segs,
+ stats->xmit_tcp_segs_gb,
+ old->xmit_tcp_segs_gb);
+
+ UPDATE_STATS_GB(stst->tcp.xmit_tcp_bytes,
+ stats->xmit_tcp_bytes_gb,
+ old->xmit_tcp_bytes_gb);
+
+ UPDATE_STATS_GB(stst->tcp.rcv_tcp_segs,
+ stats->rcv_tcp_segs_gb,
+ old->rcv_tcp_segs_gb);
+
+ UPDATE_STATS_GB(stst->tcp.rcv_tcp_bytes,
+ stats->rcv_tcp_bytes_gb,
+ old->rcv_tcp_bytes_gb);
+
+ UPDATE_STATS_GB(stst->iface.xmt_bytes,
+ stats->xmit_bytes_gb,
+ old->xmit_bytes_gb);
+
+ UPDATE_STATS_GB(stst->iface.xmt_ucast,
+ stats->xmit_unicasts_gb,
+ old->xmit_unicasts_gb);
+
+ UPDATE_STATS_GB(stst->iface.rcv_bytes,
+ stats->rcv_bytes_gb,
+ old->rcv_bytes_gb);
+
+ UPDATE_STATS_GB(stst->iface.rcv_ucast,
+ stats->rcv_unicasts_gb,
+ old->rcv_unicasts_gb);
+
+ UPDATE_STATS_GB(stst->iface.xmt_errors,
+ stats->xmit_collisions_gb,
+ old->xmit_collisions_gb);
+
+ UPDATE_STATS_GB(stst->iface.xmt_errors,
+ stats->xmit_excess_collisions_gb,
+ old->xmit_excess_collisions_gb);
+
+ UPDATE_STATS_GB(stst->iface.xmt_errors,
+ stats->xmit_other_error_gb,
+ old->xmit_other_error_gb);
+
+ UPDATE_STATS_GB(stst->iface.rcv_errors,
+ stats->rcv_other_error_gb,
+ old->rcv_other_error_gb);
+
+ UPDATE_STATS_GB(stst->iface.rcv_discards,
+ stats->rcv_drops_gb,
+ old->rcv_drops_gb);
+
+ if (stats->rcv_drops_gb > old->rcv_drops_gb)
+ adapter->rcv_drops += (stats->rcv_drops_gb -
+ old->rcv_drops_gb);
+ memcpy_fromio(old, stats, sizeof(*stats));
+ break;
+ }
case SLIC_UPR_RLSR:
slic_link_upr_complete(adapter, isr);
break;
static int slic_link_event_handler(struct adapter *adapter)
{
int status;
- struct slic_shmem *pshmem;
+ struct slic_shmemory *sm = &adapter->shmem;
+ dma_addr_t phaddr = sm->lnkstatus_phaddr;
+
if (adapter->state != ADAPT_UP) {
/* Adapter is not operational. Ignore. */
return -ENODEV;
}
-
- pshmem = (struct slic_shmem *)(unsigned long)adapter->phys_shmem;
-
-#if BITS_PER_LONG == 64
- status = slic_upr_request(adapter,
- SLIC_UPR_RLSR,
- SLIC_GET_ADDR_LOW(&pshmem->linkstatus),
- SLIC_GET_ADDR_HIGH(&pshmem->linkstatus),
- 0, 0);
-#else
+ /* no 4GB wrap guaranteed */
status = slic_upr_request(adapter, SLIC_UPR_RLSR,
- (u32)&pshmem->linkstatus, /* no 4GB wrap guaranteed */
- 0, 0, 0);
-#endif
+ cpu_to_le32(lower_32_bits(phaddr)),
+ cpu_to_le32(upper_32_bits(phaddr)), 0, 0);
return status;
}
adapter->intrregistered = 0;
free_irq(adapter->netdev->irq, adapter->netdev);
}
- if (adapter->pshmem) {
- pci_free_consistent(adapter->pcidev,
- sizeof(struct slic_shmem),
- adapter->pshmem, adapter->phys_shmem);
- adapter->pshmem = NULL;
- adapter->phys_shmem = (dma_addr_t)(unsigned long)NULL;
+
+ if (adapter->shmem.shmem_data) {
+ struct slic_shmemory *sm = &adapter->shmem;
+ struct slic_shmem_data *sm_data = sm->shmem_data;
+
+ pci_free_consistent(adapter->pcidev, sizeof(*sm_data), sm_data,
+ sm->isr_phaddr);
}
if (adapter->pingtimerset) {
{
struct net_device *dev = dev_id;
struct adapter *adapter = netdev_priv(dev);
+ struct slic_shmemory *sm = &adapter->shmem;
+ struct slic_shmem_data *sm_data = sm->shmem_data;
u32 isr;
- if ((adapter->pshmem) && (adapter->pshmem->isr)) {
+ if (sm_data->isr) {
slic_write32(adapter, SLIC_REG_ICR, ICR_INT_MASK);
slic_flush_write(adapter);
- isr = adapter->isrcopy = adapter->pshmem->isr;
- adapter->pshmem->isr = 0;
+ isr = sm_data->isr;
+ sm_data->isr = 0;
adapter->num_isrs++;
switch (adapter->card->state) {
case CARD_UP:
break;
}
- adapter->isrcopy = 0;
adapter->all_reg_writes += 2;
adapter->isr_reg_writes++;
slic_write32(adapter, SLIC_REG_ISR, 0);
{
struct sliccard *card = adapter->card;
struct net_device *dev = adapter->netdev;
- struct slic_shmem *pshmem;
+ struct slic_shmemory *sm = &adapter->shmem;
+ struct slic_shmem_data *sm_data = sm->shmem_data;
int rc;
/* adapter should be down at this point */
if (!adapter->isp_initialized) {
unsigned long flags;
- pshmem = (struct slic_shmem *)(unsigned long)
- adapter->phys_shmem;
-
spin_lock_irqsave(&adapter->bit64reglock, flags);
-
-#if BITS_PER_LONG == 64
slic_write32(adapter, SLIC_REG_ADDR_UPPER,
- SLIC_GET_ADDR_HIGH(&pshmem->isr));
+ cpu_to_le32(upper_32_bits(sm->isr_phaddr)));
slic_write32(adapter, SLIC_REG_ISP,
- SLIC_GET_ADDR_LOW(&pshmem->isr));
-#else
- slic_write32(adapter, SLIC_REG_ADDR_UPPER, 0);
- slic_write32(adapter, SLIC_REG_ISP, (u32)&pshmem->isr);
-#endif
+ cpu_to_le32(lower_32_bits(sm->isr_phaddr)));
spin_unlock_irqrestore(&adapter->bit64reglock, flags);
+
adapter->isp_initialized = 1;
}
/*
* clear any pending events, then enable interrupts
*/
- adapter->isrcopy = 0;
- adapter->pshmem->isr = 0;
+ sm_data->isr = 0;
slic_write32(adapter, SLIC_REG_ISR, 0);
slic_write32(adapter, SLIC_REG_ICR, ICR_INT_ON);
static int slic_card_init(struct sliccard *card, struct adapter *adapter)
{
+ struct slic_shmemory *sm = &adapter->shmem;
+ struct slic_shmem_data *sm_data = sm->shmem_data;
struct slic_eeprom *peeprom;
struct oslic_eeprom *pOeeprom;
dma_addr_t phys_config;
u32 phys_configh;
u32 phys_configl;
u32 i = 0;
- struct slic_shmem *pshmem;
int status;
uint macaddrs = card->card_size;
ushort eecodesize;
slic_write32(adapter, SLIC_REG_ICR, ICR_INT_OFF);
slic_flush_write(adapter);
mdelay(1);
- pshmem = (struct slic_shmem *)(unsigned long)
- adapter->phys_shmem;
spin_lock_irqsave(&adapter->bit64reglock, flags);
slic_write32(adapter, SLIC_REG_ADDR_UPPER,
- SLIC_GET_ADDR_HIGH(&pshmem->isr));
+ cpu_to_le32(upper_32_bits(sm->isr_phaddr)));
slic_write32(adapter, SLIC_REG_ISP,
- SLIC_GET_ADDR_LOW(&pshmem->isr));
+ cpu_to_le32(lower_32_bits(sm->isr_phaddr)));
spin_unlock_irqrestore(&adapter->bit64reglock, flags);
status = slic_config_get(adapter, phys_configl, phys_configh);
}
for (;;) {
- if (adapter->pshmem->isr) {
- if (adapter->pshmem->isr & ISR_UPC) {
- adapter->pshmem->isr = 0;
+ if (sm_data->isr) {
+ if (sm_data->isr & ISR_UPC) {
+ sm_data->isr = 0;
slic_write64(adapter, SLIC_REG_ISP, 0,
0);
slic_write32(adapter, SLIC_REG_ISR, 0);
break;
}
- adapter->pshmem->isr = 0;
+ sm_data->isr = 0;
slic_write32(adapter, SLIC_REG_ISR, 0);
slic_flush_write(adapter);
} else {
ushort index;
struct slic_handle *pslic_handle;
struct adapter *adapter = netdev_priv(netdev);
+ struct slic_shmemory *sm = &adapter->shmem;
+ struct slic_shmem_data *sm_data;
+ dma_addr_t phaddr;
/* adapter->pcidev = pcidev;*/
adapter->vendid = pci_tbl_entry->vendor;
pslic_handle->next = adapter->pfree_slic_handles;
adapter->pfree_slic_handles = pslic_handle;
}
- adapter->pshmem = pci_zalloc_consistent(adapter->pcidev,
- sizeof(struct slic_shmem),
- &adapter->phys_shmem);
- if (!adapter->pshmem)
+ sm_data = pci_zalloc_consistent(adapter->pcidev, sizeof(*sm_data),
+ &phaddr);
+ if (!sm_data)
return -ENOMEM;
+ sm->shmem_data = sm_data;
+ sm->isr_phaddr = phaddr;
+ sm->lnkstatus_phaddr = phaddr + offsetof(struct slic_shmem_data,
+ lnkstatus);
+ sm->stats_phaddr = phaddr + offsetof(struct slic_shmem_data, stats);
+
return 0;
}