Commit d9d578bf authored by Mithlesh Thukral's avatar Mithlesh Thukral Committed by Greg Kroah-Hartman

Staging: sxg: SXG SGL related cleanup in data structures and code

* Cleanup in allocation of SXG_SGLs.
* Locking issues related to SglQLock.
* XmtCmd and XmtZeroLock consistency fixes.
Signed-off-by: default avatarLinSysSoft Sahara Team <saharaproj@linsyssoft.com>
Signed-off-by: default avatarChristopher Harrer <charrer@alacritech.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 371d7a9e
This diff is collapsed.
......@@ -121,8 +121,9 @@ struct sxg_stats {
/* DUMB-NIC Send path definitions */
#define SXG_COMPLETE_DUMB_SEND(_pAdapt, _skb) { \
#define SXG_COMPLETE_DUMB_SEND(_pAdapt, _skb, _phys_addr, _size) { \
ASSERT(_skb); \
pci_unmap_single(_pAdapt->pcidev, _size, _phys_addr, PCI_DMA_TODEVICE); \
dev_kfree_skb_irq(_skb); \
}
......@@ -262,13 +263,19 @@ struct sxg_stats {
}
/* SGL macros */
#define SXG_FREE_SGL_BUFFER(_pAdapt, _Sgl, _NB) { \
#define SXG_FREE_SGL_BUFFER(_pAdapt, _Sgl, _NB, _irq) { \
if(!_irq) \
spin_lock_irqsave(&(_pAdapt)->SglQLock, sgl_flags); \
else \
spin_lock(&(_pAdapt)->SglQLock); \
(_pAdapt)->FreeSglBufferCount++; \
ASSERT((_pAdapt)->AllSglBufferCount >= (_pAdapt)->FreeSglBufferCount); \
ASSERT(!((_Sgl)->State & SXG_BUFFER_FREE)); \
(_Sgl)->State = SXG_BUFFER_FREE; \
InsertTailList(&(_pAdapt)->FreeSglBuffers, &(_Sgl)->FreeList); \
if(!_irq) \
spin_unlock_irqrestore(&(_pAdapt)->SglQLock, sgl_flags); \
else \
spin_unlock(&(_pAdapt)->SglQLock); \
}
......@@ -279,7 +286,7 @@ struct sxg_stats {
* until after that. We're dealing with round numbers here, so we don't need to,
* and not grabbing it avoids a possible double-trip.
*/
#define SXG_GET_SGL_BUFFER(_pAdapt, _Sgl) { \
#define SXG_GET_SGL_BUFFER(_pAdapt, _Sgl, _irq) { \
struct list_entry *_ple; \
if ((_pAdapt->FreeSglBufferCount < SXG_MIN_SGL_BUFFERS) && \
(_pAdapt->AllSglBufferCount < SXG_MAX_SGL_BUFFERS) && \
......@@ -289,6 +296,9 @@ struct sxg_stats {
SXG_BUFFER_TYPE_SGL); \
} \
_Sgl = NULL; \
if(!_irq) \
spin_lock_irqsave(&(_pAdapt)->SglQLock, sgl_flags); \
else \
spin_lock(&(_pAdapt)->SglQLock); \
if((_pAdapt)->FreeSglBufferCount) { \
ASSERT(!(IsListEmpty(&(_pAdapt)->FreeSglBuffers))); \
......@@ -300,6 +310,9 @@ struct sxg_stats {
(_Sgl)->State = SXG_BUFFER_BUSY; \
(_Sgl)->pSgl = NULL; \
} \
if(!_irq) \
spin_unlock_irqrestore(&(_pAdapt)->SglQLock, sgl_flags);\
else \
spin_unlock(&(_pAdapt)->SglQLock); \
}
......@@ -416,6 +429,7 @@ struct sxg_driver {
#undef STATUS_SUCCESS
#endif
/* TODO: We need to try and use NETDEV_TX_* before posting this out */
#define STATUS_SUCCESS 0
#define STATUS_PENDING 0
#define STATUS_FAILURE -1
......@@ -631,6 +645,10 @@ struct adapter_t {
struct sxg_rcv_ring *RcvRings; /* Receive rings */
dma_addr_t PRcvRings; /* Receive rings - physical address */
struct sxg_ucode_stats *ucode_stats; /* Ucode Stats */
/* Ucode Stats - physical address */
dma_addr_t pucode_stats;
struct sxg_ring_info RcvRingZeroInfo; /* Receive ring 0 info */
u32 * Isr; /* Interrupt status register */
......@@ -765,4 +783,5 @@ struct slic_crash_info {
#define SIOCSLICTRACEDUMP (SIOCDEVPRIVATE+11)
extern struct ethtool_ops sxg_nic_ethtool_ops;
#define SXG_COMPLETE_SLOW_SEND_LIMIT 128
#endif /* __SXG_DRIVER_H__ */
......@@ -137,7 +137,7 @@ sxg_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo)
struct adapter_t *adapter = netdev_priv(dev);
strncpy(drvinfo->driver, sxg_driver_name, 32);
strncpy(drvinfo->version, SXG_DRV_VERSION, 32);
strncpy(drvinfo->fw_version, SAHARA_UCODE_VERS_STRING, 32);
// strncpy(drvinfo->fw_version, SAHARA_UCODE_VERS_STRING, 32);
strncpy(drvinfo->bus_info, pci_name(adapter->pcidev), 32);
/* TODO : Read the major and minor number of firmware. Is this
* from the FLASH/EEPROM or download file ?
......
......@@ -486,6 +486,20 @@ struct sxg_ring_info {
SXG_RING_ADVANCE_TAIL(_ringinfo); \
}
/*
* For a given ring find out how much the first pointer is ahead of
* the second pointer. "ahead" recognises the fact that the ring can wrap
*/
static inline int sxg_ring_get_forward_diff (struct sxg_ring_info *ringinfo,
int a, int b) {
if ((a < 0 || a > ringinfo->Size ) || (b < 0 || b > ringinfo->Size))
return -1;
if (a > b) /* _a is lagging _b and _b has not wrapped around */
return (a - b);
else
return ((ringinfo->Size - (b - a)));
}
/***************************************************************
* Host Command Buffer - commands to INIC via the Cmd Rings
*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment