* [PATCH 1/4] staging: et131x: Tidy up PCI device table definition
@ 2011-10-16 12:06 Mark Einon
2011-10-16 12:06 ` [PATCH 2/4] staging: et131x: on transmit, stop the queue if the next packet will fail Mark Einon
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Mark Einon @ 2011-10-16 12:06 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel, Mark Einon
Used the convenience macros DEFINE_PCI_DEVICE_TABLE and PCI_VDEVICE to
tidy up the device table definition.
Also remove the corresponding TODO item from the README.
Signed-off-by: Mark Einon <mark.einon@gmail.com>
---
drivers/staging/et131x/README | 1 -
drivers/staging/et131x/et131x.c | 12 ++++--------
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/et131x/README b/drivers/staging/et131x/README
index 87b9360..0928eb5 100644
--- a/drivers/staging/et131x/README
+++ b/drivers/staging/et131x/README
@@ -10,7 +10,6 @@ driver as they did not build properly at the time.
TODO:
- Use of kmem_cache seems a bit unusual
- It's too late stopping the tx queue when there is no room for the current packet. The condition should be detected for the next packet.
- - PCI_VDEVICE ?
Please send patches to:
Greg Kroah-Hartman <gregkh@suse.de>
diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c
index 28d54b3..cc41111 100644
--- a/drivers/staging/et131x/et131x.c
+++ b/drivers/staging/et131x/et131x.c
@@ -169,8 +169,7 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver "
#define ET1310_PCI_REPLAY 0xC2
#define ET1310_PCI_L0L1LATENCY 0xCF
-/* PCI Vendor/Product IDs */
-#define ET131X_PCI_VENDOR_ID 0x11C1 /* Agere Systems */
+/* PCI Product IDs */
#define ET131X_PCI_DEVICE_ID_GIG 0xED00 /* ET1310 1000 Base-T 8 */
#define ET131X_PCI_DEVICE_ID_FAST 0xED01 /* ET1310 100 Base-T */
@@ -4647,14 +4646,11 @@ static SIMPLE_DEV_PM_OPS(et131x_pm_ops, et131x_suspend, et131x_resume);
#define ET131X_PM_OPS NULL
#endif
-static struct pci_device_id et131x_pci_table[] __devinitdata = {
- {ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_GIG, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0UL},
- {ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_FAST, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0UL},
+static DEFINE_PCI_DEVICE_TABLE(et131x_pci_table) = {
+ { PCI_VDEVICE(ATT, ET131X_PCI_DEVICE_ID_GIG), 0UL},
+ { PCI_VDEVICE(ATT, ET131X_PCI_DEVICE_ID_FAST), 0UL},
{0,}
};
-
MODULE_DEVICE_TABLE(pci, et131x_pci_table);
static struct pci_driver et131x_driver = {
--
1.7.6.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] staging: et131x: on transmit, stop the queue if the next packet will fail
2011-10-16 12:06 [PATCH 1/4] staging: et131x: Tidy up PCI device table definition Mark Einon
@ 2011-10-16 12:06 ` Mark Einon
2011-10-16 12:06 ` [PATCH 3/4] staging: et131x: Convert rest of pci memory management to dma api Mark Einon
2011-10-16 12:06 ` [PATCH 4/4] staging: et131x: Remove unused defines Mark Einon
2 siblings, 0 replies; 5+ messages in thread
From: Mark Einon @ 2011-10-16 12:06 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel, Mark Einon
* Currently the tx queue is only stopped when the current packet fails.
Check if the next packet will fail, and stop the queue if so.
* Removed associated item from TODO list in the README.
* Also minor fixup as adapter was being declared as null and immediately set
to a value.
Signed-off-by: Mark Einon <mark.einon@gmail.com>
---
drivers/staging/et131x/README | 1 -
drivers/staging/et131x/et131x.c | 13 ++++++-------
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/et131x/README b/drivers/staging/et131x/README
index 0928eb5..3458aa7 100644
--- a/drivers/staging/et131x/README
+++ b/drivers/staging/et131x/README
@@ -9,7 +9,6 @@ driver as they did not build properly at the time.
TODO:
- Use of kmem_cache seems a bit unusual
- - It's too late stopping the tx queue when there is no room for the current packet. The condition should be detected for the next packet.
Please send patches to:
Greg Kroah-Hartman <gregkh@suse.de>
diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c
index cc41111..993f93a 100644
--- a/drivers/staging/et131x/et131x.c
+++ b/drivers/staging/et131x/et131x.c
@@ -3448,9 +3448,7 @@ static int send_packet(struct sk_buff *skb, struct et131x_adapter *adapter)
int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev)
{
int status = 0;
- struct et131x_adapter *adapter = NULL;
-
- adapter = netdev_priv(netdev);
+ struct et131x_adapter *adapter = netdev_priv(netdev);
/* Send these packets
*
@@ -5347,6 +5345,11 @@ static void et131x_multicast(struct net_device *netdev)
static int et131x_tx(struct sk_buff *skb, struct net_device *netdev)
{
int status = 0;
+ struct et131x_adapter *adapter = netdev_priv(netdev);
+
+ /* stop the queue if it's getting full */
+ if(adapter->tx_ring.used >= NUM_TCB - 1 && !netif_queue_stopped(netdev))
+ netif_stop_queue(netdev);
/* Save the timestamp for the TX timeout watchdog */
netdev->trans_start = jiffies;
@@ -5357,10 +5360,6 @@ static int et131x_tx(struct sk_buff *skb, struct net_device *netdev)
/* Check status and manage the netif queue if necessary */
if (status != 0) {
if (status == -ENOMEM) {
- /* Put the queue to sleep until resources are
- * available
- */
- netif_stop_queue(netdev);
status = NETDEV_TX_BUSY;
} else {
status = NETDEV_TX_OK;
--
1.7.6.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] staging: et131x: Convert rest of pci memory management to dma api
2011-10-16 12:06 [PATCH 1/4] staging: et131x: Tidy up PCI device table definition Mark Einon
2011-10-16 12:06 ` [PATCH 2/4] staging: et131x: on transmit, stop the queue if the next packet will fail Mark Einon
@ 2011-10-16 12:06 ` Mark Einon
2011-10-16 16:55 ` Francois Romieu
2011-10-16 12:06 ` [PATCH 4/4] staging: et131x: Remove unused defines Mark Einon
2 siblings, 1 reply; 5+ messages in thread
From: Mark Einon @ 2011-10-16 12:06 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel, Mark Einon
Replaced pci map/unmap and set_mask calls with their dma equivalents.
Also updated comments to reflect this.
Signed-off-by: Mark Einon <mark.einon@gmail.com>
---
drivers/staging/et131x/et131x.c | 56 +++++++++++++++++++-------------------
1 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c
index 993f93a..1c11dfd 100644
--- a/drivers/staging/et131x/et131x.c
+++ b/drivers/staging/et131x/et131x.c
@@ -1976,7 +1976,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
/* Save physical address
*
- * NOTE: pci_alloc_consistent(), used above to alloc DMA regions,
+ * NOTE: dma_alloc_coherent(), used above to alloc DMA regions,
* ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses
* are ever returned, make sure the high part is retrieved here
* before storing the adjusted address.
@@ -2007,7 +2007,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
/* Save physical address
*
- * NOTE: pci_alloc_consistent(), used above to alloc DMA regions,
+ * NOTE: dma_alloc_coherent(), used above to alloc DMA regions,
* ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses
* are ever returned, make sure the high part is retrieved here before
* storing the adjusted address.
@@ -2152,7 +2152,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
(unsigned long) rx_ring->ps_ring_physaddr);
/*
- * NOTE : pci_alloc_consistent(), used above to alloc DMA regions,
+ * NOTE : dma_alloc_coherent(), used above to alloc DMA regions,
* ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses
* are ever returned, make sure the high part is retrieved here before
* storing the adjusted address.
@@ -2172,7 +2172,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
printk(KERN_INFO "PRS %lx\n", (unsigned long)rx_ring->rx_status_bus);
/* Recv
- * pci_pool_create initializes a lookaside list. After successful
+ * kmem_cache_create initializes a lookaside list. After successful
* creation, nonpaged fixed-size blocks can be allocated from and
* freed to the lookaside list.
* RFDs will be allocated from this pool.
@@ -2408,7 +2408,7 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *adapter)
/* Load the completion writeback physical address
*
- * NOTE : pci_alloc_consistent(), used above to alloc DMA regions,
+ * NOTE : dma_alloc_coherent(), used above to alloc DMA regions,
* ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses
* are ever returned, make sure the high part is retrieved here
* before storing the adjusted address.
@@ -3005,7 +3005,7 @@ int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter)
/* Save physical address
*
- * NOTE: pci_alloc_consistent(), used above to alloc DMA regions,
+ * NOTE: dma_alloc_coherent(), used above to alloc DMA regions,
* ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses
* are ever returned, make sure the high part is retrieved here before
* storing the adjusted address.
@@ -3202,59 +3202,59 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)
skb->len - skb->data_len;
/* NOTE: Here, the dma_addr_t returned from
- * pci_map_single() is implicitly cast as a
+ * dma_map_single() is implicitly cast as a
* u32. Although dma_addr_t can be
* 64-bit, the address returned by
- * pci_map_single() is always 32-bit
+ * dma_map_single() is always 32-bit
* addressable (as defined by the pci/dma
* subsystem)
*/
desc[frag++].addr_lo =
- pci_map_single(adapter->pdev,
+ dma_map_single(&adapter->pdev->dev,
skb->data,
skb->len -
skb->data_len,
- PCI_DMA_TODEVICE);
+ DMA_TO_DEVICE);
} else {
desc[frag].addr_hi = 0;
desc[frag].len_vlan =
(skb->len - skb->data_len) / 2;
/* NOTE: Here, the dma_addr_t returned from
- * pci_map_single() is implicitly cast as a
+ * dma_map_single() is implicitly cast as a
* u32. Although dma_addr_t can be
* 64-bit, the address returned by
- * pci_map_single() is always 32-bit
+ * dma_map_single() is always 32-bit
* addressable (as defined by the pci/dma
* subsystem)
*/
desc[frag++].addr_lo =
- pci_map_single(adapter->pdev,
+ dma_map_single(&adapter->pdev->dev,
skb->data,
((skb->len -
skb->data_len) / 2),
- PCI_DMA_TODEVICE);
+ DMA_TO_DEVICE);
desc[frag].addr_hi = 0;
desc[frag].len_vlan =
(skb->len - skb->data_len) / 2;
/* NOTE: Here, the dma_addr_t returned from
- * pci_map_single() is implicitly cast as a
+ * dma_map_single() is implicitly cast as a
* u32. Although dma_addr_t can be
* 64-bit, the address returned by
- * pci_map_single() is always 32-bit
+ * dma_map_single() is always 32-bit
* addressable (as defined by the pci/dma
* subsystem)
*/
desc[frag++].addr_lo =
- pci_map_single(adapter->pdev,
+ dma_map_single(&adapter->pdev->dev,
skb->data +
((skb->len -
skb->data_len) / 2),
((skb->len -
skb->data_len) / 2),
- PCI_DMA_TODEVICE);
+ DMA_TO_DEVICE);
}
} else {
desc[frag].addr_hi = 0;
@@ -3262,17 +3262,17 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)
frags[i - 1].size;
/* NOTE: Here, the dma_addr_t returned from
- * pci_map_page() is implicitly cast as a u32.
+ * dma_map_page() is implicitly cast as a u32.
* Although dma_addr_t can be 64-bit, the address
- * returned by pci_map_page() is always 32-bit
+ * returned by dma_map_page() is always 32-bit
* addressable (as defined by the pci/dma subsystem)
*/
desc[frag++].addr_lo =
- pci_map_page(adapter->pdev,
+ dma_map_page(&adapter->pdev->dev,
frags[i - 1].page,
frags[i - 1].page_offset,
frags[i - 1].size,
- PCI_DMA_TODEVICE);
+ DMA_TO_DEVICE);
}
}
@@ -3522,9 +3522,9 @@ static inline void free_send_packet(struct et131x_adapter *adapter,
(adapter->tx_ring.tx_desc_ring +
INDEX10(tcb->index_start));
- pci_unmap_single(adapter->pdev,
+ dma_unmap_single(&adapter->pdev->dev,
desc->addr_lo,
- desc->len_vlan, PCI_DMA_TODEVICE);
+ desc->len_vlan, DMA_TO_DEVICE);
add_10bit(&tcb->index_start, 1);
if (INDEX10(tcb->index_start) >=
@@ -4428,15 +4428,15 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev,
}
/* Check the DMA addressing support of this device */
- if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
- result = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
+ if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
+ result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
if (result) {
dev_err(&pdev->dev,
"Unable to obtain 64 bit DMA for consistent allocations\n");
goto err_release_res;
}
- } else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
- result = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+ } else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
+ result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
if (result) {
dev_err(&pdev->dev,
"Unable to obtain 32 bit DMA for consistent allocations\n");
--
1.7.6.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] staging: et131x: Remove unused defines
2011-10-16 12:06 [PATCH 1/4] staging: et131x: Tidy up PCI device table definition Mark Einon
2011-10-16 12:06 ` [PATCH 2/4] staging: et131x: on transmit, stop the queue if the next packet will fail Mark Einon
2011-10-16 12:06 ` [PATCH 3/4] staging: et131x: Convert rest of pci memory management to dma api Mark Einon
@ 2011-10-16 12:06 ` Mark Einon
2 siblings, 0 replies; 5+ messages in thread
From: Mark Einon @ 2011-10-16 12:06 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel, Mark Einon
Some defines are no longer referenced in the code, so removed them.
Signed-off-by: Mark Einon <mark.einon@gmail.com>
---
drivers/staging/et131x/et131x.c | 11 -----------
1 files changed, 0 insertions(+), 11 deletions(-)
diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c
index 1c11dfd..1efa27c 100644
--- a/drivers/staging/et131x/et131x.c
+++ b/drivers/staging/et131x/et131x.c
@@ -145,21 +145,14 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver "
/* MP_ADAPTER flags */
#define fMP_ADAPTER_RECV_LOOKASIDE 0x00000004
#define fMP_ADAPTER_INTERRUPT_IN_USE 0x00000008
-#define fMP_ADAPTER_SECONDARY 0x00000010
/* MP_SHARED flags */
-#define fMP_ADAPTER_SHUTDOWN 0x00100000
#define fMP_ADAPTER_LOWER_POWER 0x00200000
#define fMP_ADAPTER_NON_RECOVER_ERROR 0x00800000
-#define fMP_ADAPTER_RESET_IN_PROGRESS 0x01000000
-#define fMP_ADAPTER_NO_CABLE 0x02000000
#define fMP_ADAPTER_HARDWARE_ERROR 0x04000000
-#define fMP_ADAPTER_REMOVE_IN_PROGRESS 0x08000000
-#define fMP_ADAPTER_HALT_IN_PROGRESS 0x10000000
#define fMP_ADAPTER_FAIL_SEND_MASK 0x3ff00000
-#define fMP_ADAPTER_NOT_READY_MASK 0x3ff00000
/* Some offsets in PCI config space that are actually used. */
#define ET1310_PCI_MAX_PYLD 0x4C
@@ -205,7 +198,6 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver "
#define NUM_PACKETS_HANDLED 256
-#define ALCATEL_BAD_STATUS 0xe47f0000
#define ALCATEL_MULTICAST_PKT 0x01000000
#define ALCATEL_BROADCAST_PKT 0x02000000
@@ -452,8 +444,6 @@ struct tx_ring {
* Once the desired performance has been achieved, the optimal registry values
* should be re-populated to these #defines:
*/
-#define NUM_TRAFFIC_CLASSES 1
-
#define TX_ERROR_PERIOD 1000
#define LO_MARK_PERCENT_FOR_PSR 15
@@ -4715,7 +4705,6 @@ void et131x_disable_interrupts(struct et131x_adapter *adapter)
writel(INT_MASK_DISABLE, &adapter->regs->global.int_mask);
}
-
/**
* et131x_isr - The Interrupt Service Routine for the driver.
* @irq: the IRQ on which the interrupt was received.
--
1.7.6.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 3/4] staging: et131x: Convert rest of pci memory management to dma api
2011-10-16 12:06 ` [PATCH 3/4] staging: et131x: Convert rest of pci memory management to dma api Mark Einon
@ 2011-10-16 16:55 ` Francois Romieu
0 siblings, 0 replies; 5+ messages in thread
From: Francois Romieu @ 2011-10-16 16:55 UTC (permalink / raw)
To: Mark Einon; +Cc: gregkh, devel, linux-kernel
Mark Einon <mark.einon@gmail.com> :
> Replaced pci map/unmap and set_mask calls with their dma equivalents.
> Also updated comments to reflect this.
>
> Signed-off-by: Mark Einon <mark.einon@gmail.com>
> ---
> drivers/staging/et131x/et131x.c | 56 +++++++++++++++++++-------------------
> 1 files changed, 28 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c
> index 993f93a..1c11dfd 100644
> --- a/drivers/staging/et131x/et131x.c
> +++ b/drivers/staging/et131x/et131x.c
> @@ -3202,59 +3202,59 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)
[...]
> desc[frag++].addr_lo =
> - pci_map_single(adapter->pdev,
> + dma_map_single(&adapter->pdev->dev,
> skb->data,
> skb->len -
> skb->data_len,
> - PCI_DMA_TODEVICE);
> + DMA_TO_DEVICE);
> } else {
- Some dma_mapping_error() would be welcome.
- (nit) If you keep repeating &adapter->pdev->dev, you may consider adding
some local variable
- could you rework the Tx path as well so that despite the cascade of
method the code does not end fighting for the right end of the screen ?
et131x_tx is almost empty. It could make some sense to merge it with
its callee (and rename it et131x_start_xmit ?).
- nic_send_packet
for (i = 0; i < nr_frags; i++) {
[...comment..]
if (i == 0) {
Lovely...
[big block]
} else {
[small block]
}
... really, really lovely.
}
[...]
> /* NOTE: Here, the dma_addr_t returned from
> - * pci_map_single() is implicitly cast as a
> + * dma_map_single() is implicitly cast as a
> * u32. Although dma_addr_t can be
> * 64-bit, the address returned by
> - * pci_map_single() is always 32-bit
> + * dma_map_single() is always 32-bit
> * addressable (as defined by the pci/dma
> * subsystem)
> */
> desc[frag++].addr_lo =
[...]
> desc[frag].addr_hi = 0;
- The NOTE seems a bit outdated. Afaiks the driver tries to set a 64 bits
wide DMA mask. Both addr_lo and addr_hi should be set with the returned
mapping and/or even replaced with a single 64 bits addr field in tx_desc.
- Speaking of it, tx_desc probably lacks some __leXY annotations.
- (nic_send_packet)
{
u32 i;
struct tx_desc desc[24]; /* 24 x 16 byte */
384 bytes. :o/
--
Ueimor
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-10-16 16:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-16 12:06 [PATCH 1/4] staging: et131x: Tidy up PCI device table definition Mark Einon
2011-10-16 12:06 ` [PATCH 2/4] staging: et131x: on transmit, stop the queue if the next packet will fail Mark Einon
2011-10-16 12:06 ` [PATCH 3/4] staging: et131x: Convert rest of pci memory management to dma api Mark Einon
2011-10-16 16:55 ` Francois Romieu
2011-10-16 12:06 ` [PATCH 4/4] staging: et131x: Remove unused defines Mark Einon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox