Commit 3e0f75be authored by Francois Romieu's avatar Francois Romieu Committed by Jeff Garzik

chelsio: misc cleanups in sge

- duplicated code in sge::free_cmdQ_buffers ;
- NET_IP_ALIGN is already defined in (included) <linux/skbuff.h> ;
- pci_alloc_consistent() returns void * ;
- pci_alloc_consistent() returns a zeroed chunk of memory ;
- early return in restart_tx_queues.
Signed-off-by: default avatarFrancois Romieu <romieu@fr.zoreil.com>
parent 47cbe6f4
...@@ -85,10 +85,6 @@ ...@@ -85,10 +85,6 @@
*/ */
#define TX_RECLAIM_PERIOD (HZ / 4) #define TX_RECLAIM_PERIOD (HZ / 4)
#ifndef NET_IP_ALIGN
# define NET_IP_ALIGN 2
#endif
#define M_CMD_LEN 0x7fffffff #define M_CMD_LEN 0x7fffffff
#define V_CMD_LEN(v) (v) #define V_CMD_LEN(v) (v)
#define G_CMD_LEN(v) ((v) & M_CMD_LEN) #define G_CMD_LEN(v) ((v) & M_CMD_LEN)
...@@ -575,11 +571,10 @@ static int alloc_rx_resources(struct sge *sge, struct sge_params *p) ...@@ -575,11 +571,10 @@ static int alloc_rx_resources(struct sge *sge, struct sge_params *p)
q->size = p->freelQ_size[i]; q->size = p->freelQ_size[i];
q->dma_offset = sge->rx_pkt_pad ? 0 : NET_IP_ALIGN; q->dma_offset = sge->rx_pkt_pad ? 0 : NET_IP_ALIGN;
size = sizeof(struct freelQ_e) * q->size; size = sizeof(struct freelQ_e) * q->size;
q->entries = (struct freelQ_e *) q->entries = pci_alloc_consistent(pdev, size, &q->dma_addr);
pci_alloc_consistent(pdev, size, &q->dma_addr);
if (!q->entries) if (!q->entries)
goto err_no_mem; goto err_no_mem;
memset(q->entries, 0, size);
size = sizeof(struct freelQ_ce) * q->size; size = sizeof(struct freelQ_ce) * q->size;
q->centries = kzalloc(size, GFP_KERNEL); q->centries = kzalloc(size, GFP_KERNEL);
if (!q->centries) if (!q->centries)
...@@ -613,11 +608,10 @@ static int alloc_rx_resources(struct sge *sge, struct sge_params *p) ...@@ -613,11 +608,10 @@ static int alloc_rx_resources(struct sge *sge, struct sge_params *p)
sge->respQ.size = SGE_RESPQ_E_N; sge->respQ.size = SGE_RESPQ_E_N;
sge->respQ.credits = 0; sge->respQ.credits = 0;
size = sizeof(struct respQ_e) * sge->respQ.size; size = sizeof(struct respQ_e) * sge->respQ.size;
sge->respQ.entries = (struct respQ_e *) sge->respQ.entries =
pci_alloc_consistent(pdev, size, &sge->respQ.dma_addr); pci_alloc_consistent(pdev, size, &sge->respQ.dma_addr);
if (!sge->respQ.entries) if (!sge->respQ.entries)
goto err_no_mem; goto err_no_mem;
memset(sge->respQ.entries, 0, size);
return 0; return 0;
err_no_mem: err_no_mem:
...@@ -637,21 +631,13 @@ static void free_cmdQ_buffers(struct sge *sge, struct cmdQ *q, unsigned int n) ...@@ -637,21 +631,13 @@ static void free_cmdQ_buffers(struct sge *sge, struct cmdQ *q, unsigned int n)
q->in_use -= n; q->in_use -= n;
ce = &q->centries[cidx]; ce = &q->centries[cidx];
while (n--) { while (n--) {
if (q->sop) {
if (likely(pci_unmap_len(ce, dma_len))) { if (likely(pci_unmap_len(ce, dma_len))) {
pci_unmap_single(pdev, pci_unmap_single(pdev, pci_unmap_addr(ce, dma_addr),
pci_unmap_addr(ce, dma_addr),
pci_unmap_len(ce, dma_len), pci_unmap_len(ce, dma_len),
PCI_DMA_TODEVICE); PCI_DMA_TODEVICE);
if (q->sop)
q->sop = 0; q->sop = 0;
} }
} else {
if (likely(pci_unmap_len(ce, dma_len))) {
pci_unmap_page(pdev, pci_unmap_addr(ce, dma_addr),
pci_unmap_len(ce, dma_len),
PCI_DMA_TODEVICE);
}
}
if (ce->skb) { if (ce->skb) {
dev_kfree_skb_any(ce->skb); dev_kfree_skb_any(ce->skb);
q->sop = 1; q->sop = 1;
...@@ -711,11 +697,10 @@ static int alloc_tx_resources(struct sge *sge, struct sge_params *p) ...@@ -711,11 +697,10 @@ static int alloc_tx_resources(struct sge *sge, struct sge_params *p)
q->stop_thres = 0; q->stop_thres = 0;
spin_lock_init(&q->lock); spin_lock_init(&q->lock);
size = sizeof(struct cmdQ_e) * q->size; size = sizeof(struct cmdQ_e) * q->size;
q->entries = (struct cmdQ_e *) q->entries = pci_alloc_consistent(pdev, size, &q->dma_addr);
pci_alloc_consistent(pdev, size, &q->dma_addr);
if (!q->entries) if (!q->entries)
goto err_no_mem; goto err_no_mem;
memset(q->entries, 0, size);
size = sizeof(struct cmdQ_ce) * q->size; size = sizeof(struct cmdQ_ce) * q->size;
q->centries = kzalloc(size, GFP_KERNEL); q->centries = kzalloc(size, GFP_KERNEL);
if (!q->centries) if (!q->centries)
...@@ -1447,21 +1432,20 @@ static inline int enough_free_Tx_descs(const struct cmdQ *q) ...@@ -1447,21 +1432,20 @@ static inline int enough_free_Tx_descs(const struct cmdQ *q)
static void restart_tx_queues(struct sge *sge) static void restart_tx_queues(struct sge *sge)
{ {
struct adapter *adap = sge->adapter; struct adapter *adap = sge->adapter;
if (enough_free_Tx_descs(&sge->cmdQ[0])) {
int i; int i;
if (!enough_free_Tx_descs(&sge->cmdQ[0]))
return;
for_each_port(adap, i) { for_each_port(adap, i) {
struct net_device *nd = adap->port[i].dev; struct net_device *nd = adap->port[i].dev;
if (test_and_clear_bit(nd->if_port, if (test_and_clear_bit(nd->if_port, &sge->stopped_tx_queues) &&
&sge->stopped_tx_queues) &&
netif_running(nd)) { netif_running(nd)) {
sge->stats.cmdQ_restarted[2]++; sge->stats.cmdQ_restarted[2]++;
netif_wake_queue(nd); netif_wake_queue(nd);
} }
} }
}
} }
/* /*
......
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