* [PATCH 0/4]qlcnic: bug fixes @ 2010-10-26 9:37 Amit Kumar Salecha 2010-10-26 9:37 ` [PATCH] qlcnic: fix mac learning Amit Kumar Salecha ` (4 more replies) 0 siblings, 5 replies; 12+ messages in thread From: Amit Kumar Salecha @ 2010-10-26 9:37 UTC (permalink / raw) To: davem; +Cc: netdev, ameen.rahman, anirban.chakraborty Hi Series of 4 bug fixes. Apply them on net-2.6 branch. -Amit ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] qlcnic: fix mac learning 2010-10-26 9:37 [PATCH 0/4]qlcnic: bug fixes Amit Kumar Salecha @ 2010-10-26 9:37 ` Amit Kumar Salecha 2010-10-26 9:38 ` [PATCH] qlcnic: reduce RX ring size for nic partition Amit Kumar Salecha ` (3 subsequent siblings) 4 siblings, 0 replies; 12+ messages in thread From: Amit Kumar Salecha @ 2010-10-26 9:37 UTC (permalink / raw) To: davem; +Cc: netdev, ameen.rahman, anirban.chakraborty In failover bonding case, same mac address can be programmed on other slave function. Fw will delete old entry (original func) associated with that mac address. Need to reporgram mac address, if failover again happen to original function. Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com> --- drivers/net/qlcnic/qlcnic.h | 1 + drivers/net/qlcnic/qlcnic_main.c | 5 +++++ 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/drivers/net/qlcnic/qlcnic.h b/drivers/net/qlcnic/qlcnic.h index 26c37d3..a60ff17 100644 --- a/drivers/net/qlcnic/qlcnic.h +++ b/drivers/net/qlcnic/qlcnic.h @@ -942,6 +942,7 @@ struct qlcnic_ipaddr { #define QLCNIC_LOOPBACK_TEST 2 #define QLCNIC_FILTER_AGE 80 +#define QLCNIC_READD_AGE 20 #define QLCNIC_LB_MAX_FILTERS 64 struct qlcnic_filter { diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c index f047c7c..5a3ce08 100644 --- a/drivers/net/qlcnic/qlcnic_main.c +++ b/drivers/net/qlcnic/qlcnic_main.c @@ -1860,6 +1860,11 @@ qlcnic_send_filter(struct qlcnic_adapter *adapter, hlist_for_each_entry_safe(tmp_fil, tmp_hnode, n, head, fnode) { if (!memcmp(tmp_fil->faddr, &src_addr, ETH_ALEN) && tmp_fil->vlan_id == vlan_id) { + + if (jiffies > + (QLCNIC_READD_AGE * HZ + tmp_fil->ftime)) + qlcnic_change_filter(adapter, src_addr, vlan_id, + tx_ring); tmp_fil->ftime = jiffies; return; } -- 1.6.0.2 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH] qlcnic: reduce RX ring size for nic partition 2010-10-26 9:37 [PATCH 0/4]qlcnic: bug fixes Amit Kumar Salecha 2010-10-26 9:37 ` [PATCH] qlcnic: fix mac learning Amit Kumar Salecha @ 2010-10-26 9:38 ` Amit Kumar Salecha 2010-10-26 9:38 ` [PATCH] qlcnic: define valid vlan id range Amit Kumar Salecha ` (2 subsequent siblings) 4 siblings, 0 replies; 12+ messages in thread From: Amit Kumar Salecha @ 2010-10-26 9:38 UTC (permalink / raw) To: davem; +Cc: netdev, ameen.rahman, anirban.chakraborty, Sony Chacko From: Sony Chacko <sony.chacko@qlogic.com> For NIC Partition adapter, rcv ring size can be reduce, as physical port is partition-ed. Signed-off-by: Sony Chacko <sony.chacko@qlogic.com> Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com> --- drivers/net/qlcnic/qlcnic.h | 4 ++++ drivers/net/qlcnic/qlcnic_ethtool.c | 23 +++++------------------ drivers/net/qlcnic/qlcnic_main.c | 14 ++++++++++++-- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/drivers/net/qlcnic/qlcnic.h b/drivers/net/qlcnic/qlcnic.h index a60ff17..6400e6a 100644 --- a/drivers/net/qlcnic/qlcnic.h +++ b/drivers/net/qlcnic/qlcnic.h @@ -146,11 +146,13 @@ #define MAX_CMD_DESCRIPTORS 1024 #define MAX_RCV_DESCRIPTORS_1G 4096 #define MAX_RCV_DESCRIPTORS_10G 8192 +#define MAX_RCV_DESCRIPTORS_VF 2048 #define MAX_JUMBO_RCV_DESCRIPTORS_1G 512 #define MAX_JUMBO_RCV_DESCRIPTORS_10G 1024 #define DEFAULT_RCV_DESCRIPTORS_1G 2048 #define DEFAULT_RCV_DESCRIPTORS_10G 4096 +#define DEFAULT_RCV_DESCRIPTORS_VF 1024 #define MAX_RDS_RINGS 2 #define get_next_index(index, length) \ @@ -971,6 +973,8 @@ struct qlcnic_adapter { u16 num_txd; u16 num_rxd; u16 num_jumbo_rxd; + u16 max_rxd; + u16 max_jumbo_rxd; u8 max_rds_rings; u8 max_sds_rings; diff --git a/drivers/net/qlcnic/qlcnic_ethtool.c b/drivers/net/qlcnic/qlcnic_ethtool.c index 25e93a5..ec21d24 100644 --- a/drivers/net/qlcnic/qlcnic_ethtool.c +++ b/drivers/net/qlcnic/qlcnic_ethtool.c @@ -437,14 +437,8 @@ qlcnic_get_ringparam(struct net_device *dev, ring->rx_jumbo_pending = adapter->num_jumbo_rxd; ring->tx_pending = adapter->num_txd; - if (adapter->ahw.port_type == QLCNIC_GBE) { - ring->rx_max_pending = MAX_RCV_DESCRIPTORS_1G; - ring->rx_jumbo_max_pending = MAX_JUMBO_RCV_DESCRIPTORS_1G; - } else { - ring->rx_max_pending = MAX_RCV_DESCRIPTORS_10G; - ring->rx_jumbo_max_pending = MAX_JUMBO_RCV_DESCRIPTORS_10G; - } - + ring->rx_max_pending = adapter->max_rxd; + ring->rx_jumbo_max_pending = adapter->max_jumbo_rxd; ring->tx_max_pending = MAX_CMD_DESCRIPTORS; ring->rx_mini_max_pending = 0; @@ -472,24 +466,17 @@ qlcnic_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) { struct qlcnic_adapter *adapter = netdev_priv(dev); - u16 max_rcv_desc = MAX_RCV_DESCRIPTORS_10G; - u16 max_jumbo_desc = MAX_JUMBO_RCV_DESCRIPTORS_10G; u16 num_rxd, num_jumbo_rxd, num_txd; - if (ring->rx_mini_pending) return -EOPNOTSUPP; - if (adapter->ahw.port_type == QLCNIC_GBE) { - max_rcv_desc = MAX_RCV_DESCRIPTORS_1G; - max_jumbo_desc = MAX_JUMBO_RCV_DESCRIPTORS_10G; - } - num_rxd = qlcnic_validate_ringparam(ring->rx_pending, - MIN_RCV_DESCRIPTORS, max_rcv_desc, "rx"); + MIN_RCV_DESCRIPTORS, adapter->max_rxd, "rx"); num_jumbo_rxd = qlcnic_validate_ringparam(ring->rx_jumbo_pending, - MIN_JUMBO_DESCRIPTORS, max_jumbo_desc, "rx jumbo"); + MIN_JUMBO_DESCRIPTORS, adapter->max_jumbo_rxd, + "rx jumbo"); num_txd = qlcnic_validate_ringparam(ring->tx_pending, MIN_CMD_DESCRIPTORS, MAX_CMD_DESCRIPTORS, "tx"); diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c index 5a3ce08..7a298cd 100644 --- a/drivers/net/qlcnic/qlcnic_main.c +++ b/drivers/net/qlcnic/qlcnic_main.c @@ -656,13 +656,23 @@ qlcnic_check_options(struct qlcnic_adapter *adapter) dev_info(&pdev->dev, "firmware v%d.%d.%d\n", fw_major, fw_minor, fw_build); - if (adapter->ahw.port_type == QLCNIC_XGBE) { - adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_10G; + if (adapter->flags & QLCNIC_ESWITCH_ENABLED) { + adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_VF; + adapter->max_rxd = MAX_RCV_DESCRIPTORS_VF; + } else { + adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_10G; + adapter->max_rxd = MAX_RCV_DESCRIPTORS_10G; + } + adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G; + adapter->max_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G; + } else if (adapter->ahw.port_type == QLCNIC_GBE) { adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_1G; adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_1G; + adapter->max_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_1G; + adapter->max_rxd = MAX_RCV_DESCRIPTORS_1G; } adapter->msix_supported = !!use_msi_x; -- 1.6.0.2 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH] qlcnic: define valid vlan id range 2010-10-26 9:37 [PATCH 0/4]qlcnic: bug fixes Amit Kumar Salecha 2010-10-26 9:37 ` [PATCH] qlcnic: fix mac learning Amit Kumar Salecha 2010-10-26 9:38 ` [PATCH] qlcnic: reduce RX ring size for nic partition Amit Kumar Salecha @ 2010-10-26 9:38 ` Amit Kumar Salecha 2010-10-26 9:38 ` [PATCH] qlcnic: dma address align check Amit Kumar Salecha 2010-10-26 15:37 ` [PATCH 0/4]qlcnic: bug fixes David Miller 4 siblings, 0 replies; 12+ messages in thread From: Amit Kumar Salecha @ 2010-10-26 9:38 UTC (permalink / raw) To: davem; +Cc: netdev, ameen.rahman, anirban.chakraborty, Sony Chacko From: Sony Chacko <sony.chacko@qlogic.com> 4095 vlan id is reserved and should not be use. Signed-off-by: Sony Chacko <sony.chacko@qlogic.com> Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com> --- drivers/net/qlcnic/qlcnic.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/net/qlcnic/qlcnic.h b/drivers/net/qlcnic/qlcnic.h index 6400e6a..8ecc170 100644 --- a/drivers/net/qlcnic/qlcnic.h +++ b/drivers/net/qlcnic/qlcnic.h @@ -1134,7 +1134,7 @@ struct qlcnic_eswitch { #define MAX_RX_QUEUES 4 #define DEFAULT_MAC_LEARN 1 -#define IS_VALID_VLAN(vlan) (vlan >= MIN_VLAN_ID && vlan <= MAX_VLAN_ID) +#define IS_VALID_VLAN(vlan) (vlan >= MIN_VLAN_ID && vlan < MAX_VLAN_ID) #define IS_VALID_BW(bw) (bw >= MIN_BW && bw <= MAX_BW) #define IS_VALID_TX_QUEUES(que) (que > 0 && que <= MAX_TX_QUEUES) #define IS_VALID_RX_QUEUES(que) (que > 0 && que <= MAX_RX_QUEUES) -- 1.6.0.2 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH] qlcnic: dma address align check 2010-10-26 9:37 [PATCH 0/4]qlcnic: bug fixes Amit Kumar Salecha ` (2 preceding siblings ...) 2010-10-26 9:38 ` [PATCH] qlcnic: define valid vlan id range Amit Kumar Salecha @ 2010-10-26 9:38 ` Amit Kumar Salecha 2010-10-26 9:54 ` Eric Dumazet 2010-10-26 15:37 ` [PATCH 0/4]qlcnic: bug fixes David Miller 4 siblings, 1 reply; 12+ messages in thread From: Amit Kumar Salecha @ 2010-10-26 9:38 UTC (permalink / raw) To: davem; +Cc: netdev, ameen.rahman, anirban.chakraborty Device requires tx_hw_cosnumer to be 64 byte aligned. Tx desc size is 64 byte, alloc tx_hw_consumer with tx desc. Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com> --- drivers/net/qlcnic/qlcnic_ctx.c | 35 +++++++++++++++-------------------- 1 files changed, 15 insertions(+), 20 deletions(-) diff --git a/drivers/net/qlcnic/qlcnic_ctx.c b/drivers/net/qlcnic/qlcnic_ctx.c index 1cdc05d..21c9c28 100644 --- a/drivers/net/qlcnic/qlcnic_ctx.c +++ b/drivers/net/qlcnic/qlcnic_ctx.c @@ -418,18 +418,9 @@ int qlcnic_alloc_hw_resources(struct qlcnic_adapter *adapter) recv_ctx = &adapter->recv_ctx; tx_ring = adapter->tx_ring; - tx_ring->hw_consumer = (__le32 *)pci_alloc_consistent(pdev, sizeof(u32), - &tx_ring->hw_cons_phys_addr); - if (tx_ring->hw_consumer == NULL) { - dev_err(&pdev->dev, "failed to allocate tx consumer\n"); - return -ENOMEM; - } - *(tx_ring->hw_consumer) = 0; - /* cmd desc ring */ - addr = pci_alloc_consistent(pdev, TX_DESC_RINGSIZE(tx_ring), - &tx_ring->phys_addr); - + addr = pci_alloc_consistent(pdev, TX_DESC_RINGSIZE(tx_ring) + + sizeof(u32), &tx_ring->phys_addr); if (addr == NULL) { dev_err(&pdev->dev, "failed to allocate tx desc ring\n"); err = -ENOMEM; @@ -437,6 +428,17 @@ int qlcnic_alloc_hw_resources(struct qlcnic_adapter *adapter) } tx_ring->desc_head = (struct cmd_desc_type0 *)addr; + tx_ring->hw_consumer = (__le32 *)(((char *)addr) + + TX_DESC_RINGSIZE(tx_ring)); + tx_ring->hw_cons_phys_addr = (dma_addr_t)(((char *)tx_ring->phys_addr) + + TX_DESC_RINGSIZE(tx_ring)); + if (tx_ring->hw_cons_phys_addr & 0x3F) { + dev_err(&pdev->dev, "Device requires 64 byte aligned dma addr" + ". dma_addr=%p\n", (void *)tx_ring->hw_cons_phys_addr); + err = -ENOMEM; + goto err_out_free; + } + *(tx_ring->hw_consumer) = 0; for (ring = 0; ring < adapter->max_rds_rings; ring++) { rds_ring = &recv_ctx->rds_rings[ring]; @@ -516,19 +518,12 @@ void qlcnic_free_hw_resources(struct qlcnic_adapter *adapter) recv_ctx = &adapter->recv_ctx; tx_ring = adapter->tx_ring; - if (tx_ring->hw_consumer != NULL) { - pci_free_consistent(adapter->pdev, - sizeof(u32), - tx_ring->hw_consumer, - tx_ring->hw_cons_phys_addr); - tx_ring->hw_consumer = NULL; - } - if (tx_ring->desc_head != NULL) { pci_free_consistent(adapter->pdev, - TX_DESC_RINGSIZE(tx_ring), + TX_DESC_RINGSIZE(tx_ring) + sizeof(u32), tx_ring->desc_head, tx_ring->phys_addr); tx_ring->desc_head = NULL; + tx_ring->hw_consumer = NULL; } for (ring = 0; ring < adapter->max_rds_rings; ring++) { -- 1.6.0.2 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] qlcnic: dma address align check 2010-10-26 9:38 ` [PATCH] qlcnic: dma address align check Amit Kumar Salecha @ 2010-10-26 9:54 ` Eric Dumazet 2010-10-26 10:04 ` Amit Salecha 0 siblings, 1 reply; 12+ messages in thread From: Eric Dumazet @ 2010-10-26 9:54 UTC (permalink / raw) To: Amit Kumar Salecha; +Cc: davem, netdev, ameen.rahman, anirban.chakraborty Le mardi 26 octobre 2010 à 02:38 -0700, Amit Kumar Salecha a écrit : > Device requires tx_hw_cosnumer to be 64 byte aligned. > Tx desc size is 64 byte, alloc tx_hw_consumer with tx desc. > > Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com> > --- > drivers/net/qlcnic/qlcnic_ctx.c | 35 +++++++++++++++-------------------- > 1 files changed, 15 insertions(+), 20 deletions(-) > > diff --git a/drivers/net/qlcnic/qlcnic_ctx.c b/drivers/net/qlcnic/qlcnic_ctx.c > index 1cdc05d..21c9c28 100644 > --- a/drivers/net/qlcnic/qlcnic_ctx.c > +++ b/drivers/net/qlcnic/qlcnic_ctx.c > @@ -418,18 +418,9 @@ int qlcnic_alloc_hw_resources(struct qlcnic_adapter *adapter) > recv_ctx = &adapter->recv_ctx; > tx_ring = adapter->tx_ring; > > - tx_ring->hw_consumer = (__le32 *)pci_alloc_consistent(pdev, sizeof(u32), > - &tx_ring->hw_cons_phys_addr); > - if (tx_ring->hw_consumer == NULL) { > - dev_err(&pdev->dev, "failed to allocate tx consumer\n"); > - return -ENOMEM; > - } > - *(tx_ring->hw_consumer) = 0; > - > /* cmd desc ring */ > - addr = pci_alloc_consistent(pdev, TX_DESC_RINGSIZE(tx_ring), > - &tx_ring->phys_addr); > - > + addr = pci_alloc_consistent(pdev, TX_DESC_RINGSIZE(tx_ring) + > + sizeof(u32), &tx_ring->phys_addr); Wont this use twice memory than before, due to power-of-two allocations ? Allocating 65536 + 4 bytes gives you 131072 bytes. ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH] qlcnic: dma address align check 2010-10-26 9:54 ` Eric Dumazet @ 2010-10-26 10:04 ` Amit Salecha 2010-10-26 10:30 ` Eric Dumazet 0 siblings, 1 reply; 12+ messages in thread From: Amit Salecha @ 2010-10-26 10:04 UTC (permalink / raw) To: Eric Dumazet Cc: davem@davemloft.net, netdev@vger.kernel.org, Ameen Rahman, Anirban Chakraborty > -----Original Message----- > From: Eric Dumazet [mailto:eric.dumazet@gmail.com] > Sent: Tuesday, October 26, 2010 3:25 PM > To: Amit Salecha > Cc: davem@davemloft.net; netdev@vger.kernel.org; Ameen Rahman; Anirban > Chakraborty > Subject: Re: [PATCH] qlcnic: dma address align check > > Le mardi 26 octobre 2010 à 02:38 -0700, Amit Kumar Salecha a écrit : > > Device requires tx_hw_cosnumer to be 64 byte aligned. > > Tx desc size is 64 byte, alloc tx_hw_consumer with tx desc. > > > > Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com> > > --- > > drivers/net/qlcnic/qlcnic_ctx.c | 35 +++++++++++++++-------------- > ------ > > 1 files changed, 15 insertions(+), 20 deletions(-) > > > > diff --git a/drivers/net/qlcnic/qlcnic_ctx.c > b/drivers/net/qlcnic/qlcnic_ctx.c > > index 1cdc05d..21c9c28 100644 > > --- a/drivers/net/qlcnic/qlcnic_ctx.c > > +++ b/drivers/net/qlcnic/qlcnic_ctx.c > > @@ -418,18 +418,9 @@ int qlcnic_alloc_hw_resources(struct > qlcnic_adapter *adapter) > > recv_ctx = &adapter->recv_ctx; > > tx_ring = adapter->tx_ring; > > > > - tx_ring->hw_consumer = (__le32 *)pci_alloc_consistent(pdev, > sizeof(u32), > > - &tx_ring->hw_cons_phys_addr); > > - if (tx_ring->hw_consumer == NULL) { > > - dev_err(&pdev->dev, "failed to allocate tx consumer\n"); > > - return -ENOMEM; > > - } > > - *(tx_ring->hw_consumer) = 0; > > - > > /* cmd desc ring */ > > - addr = pci_alloc_consistent(pdev, TX_DESC_RINGSIZE(tx_ring), > > - &tx_ring->phys_addr); > > - > > + addr = pci_alloc_consistent(pdev, TX_DESC_RINGSIZE(tx_ring) + > > + sizeof(u32), &tx_ring->phys_addr); > > Wont this use twice memory than before, due to power-of-two > allocations ? > > Allocating 65536 + 4 bytes gives you 131072 bytes. > Is it ? I am not aware about such calculation. Is pci_alloc_consistent guarantee to give PAGE align dma address ? -Amit ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH] qlcnic: dma address align check 2010-10-26 10:04 ` Amit Salecha @ 2010-10-26 10:30 ` Eric Dumazet 2010-10-26 10:52 ` Amit Salecha 2010-10-26 12:03 ` [PATCH net-next-2.6] tg3: use dma_alloc_coherent() instead of pci_alloc_consistent() Eric Dumazet 0 siblings, 2 replies; 12+ messages in thread From: Eric Dumazet @ 2010-10-26 10:30 UTC (permalink / raw) To: Amit Salecha Cc: davem@davemloft.net, netdev@vger.kernel.org, Ameen Rahman, Anirban Chakraborty Le mardi 26 octobre 2010 à 05:04 -0500, Amit Salecha a écrit : > Is it ? I am not aware about such calculation. Yes it is > Is pci_alloc_consistent guarantee to give PAGE align dma address ? I believe so By the way, you should use dma_alloc_coherent() instead of pci_alloc_consistent() so that you can use GFP_KERNEL allocations instead of GFP_ATOMIC, it might help in low memory conditions (if you dont hold a spinlock at this point) If TX_DESC_RINGSIZE(tx_ring) is not a power of two, then yes you could probably add 64 bytes and avoid allocating a full page only for the u32 field ;) ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH] qlcnic: dma address align check 2010-10-26 10:30 ` Eric Dumazet @ 2010-10-26 10:52 ` Amit Salecha 2010-10-26 12:03 ` [PATCH net-next-2.6] tg3: use dma_alloc_coherent() instead of pci_alloc_consistent() Eric Dumazet 1 sibling, 0 replies; 12+ messages in thread From: Amit Salecha @ 2010-10-26 10:52 UTC (permalink / raw) To: Eric Dumazet Cc: davem@davemloft.net, netdev@vger.kernel.org, Ameen Rahman, Anirban Chakraborty > > Is pci_alloc_consistent guarantee to give PAGE align dma address ? > > I believe so > > By the way, you should use dma_alloc_coherent() instead of > pci_alloc_consistent() so that you can use GFP_KERNEL allocations > instead of GFP_ATOMIC, it might help in low memory conditions (if you > dont hold a spinlock at this point) > > > If TX_DESC_RINGSIZE(tx_ring) is not a power of two, then yes you could > probably add 64 bytes and avoid allocating a full page only for the u32 > field ;) > > TX_DESC_RINGSIZE is power of two. If pci_alloc_consistent guarantee to give PAGE align dma address, then this patch is not required. > ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH net-next-2.6] tg3: use dma_alloc_coherent() instead of pci_alloc_consistent() 2010-10-26 10:30 ` Eric Dumazet 2010-10-26 10:52 ` Amit Salecha @ 2010-10-26 12:03 ` Eric Dumazet 2010-10-26 17:04 ` Matt Carlson 1 sibling, 1 reply; 12+ messages in thread From: Eric Dumazet @ 2010-10-26 12:03 UTC (permalink / raw) To: Amit Salecha, Matt Carlson Cc: davem@davemloft.net, netdev@vger.kernel.org, Ameen Rahman, Anirban Chakraborty, Michael Chan Le mardi 26 octobre 2010 à 12:30 +0200, Eric Dumazet a écrit : > By the way, you should use dma_alloc_coherent() instead of > pci_alloc_consistent() so that you can use GFP_KERNEL allocations > instead of GFP_ATOMIC, it might help in low memory conditions (if you > dont hold a spinlock at this point) > tg3 being often used as a reference network driver, I believe we should change its allocations before too many people copy paste suboptimal pci_alloc_consistent() stuff... Matt, could you please queue this patch and submit it to David when net-next-2.6 reopens ? Thanks [PATCH] tg3: use dma_alloc_coherent() instead of pci_alloc_consistent() Using dma_alloc_coherent() permits to use GFP_KERNEL allocations instead of GFP_ATOMIC ones. Its better when a machine is out of memory, because this allows driver to sleep to get its memory and succeed its init, especially when allocating high order pages. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> CC: Matt Carlson <mcarlson@broadcom.com> CC: Michael Chan <mchan@broadcom.com> --- drivers/net/tg3.c | 73 ++++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 852e917..7dfa579 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -6339,13 +6339,13 @@ static void tg3_rx_prodring_fini(struct tg3 *tp, kfree(tpr->rx_jmb_buffers); tpr->rx_jmb_buffers = NULL; if (tpr->rx_std) { - pci_free_consistent(tp->pdev, TG3_RX_STD_RING_BYTES(tp), - tpr->rx_std, tpr->rx_std_mapping); + dma_free_coherent(&tp->pdev->dev, TG3_RX_STD_RING_BYTES(tp), + tpr->rx_std, tpr->rx_std_mapping); tpr->rx_std = NULL; } if (tpr->rx_jmb) { - pci_free_consistent(tp->pdev, TG3_RX_JMB_RING_BYTES(tp), - tpr->rx_jmb, tpr->rx_jmb_mapping); + dma_free_coherent(&tp->pdev->dev, TG3_RX_JMB_RING_BYTES(tp), + tpr->rx_jmb, tpr->rx_jmb_mapping); tpr->rx_jmb = NULL; } } @@ -6358,8 +6358,10 @@ static int tg3_rx_prodring_init(struct tg3 *tp, if (!tpr->rx_std_buffers) return -ENOMEM; - tpr->rx_std = pci_alloc_consistent(tp->pdev, TG3_RX_STD_RING_BYTES(tp), - &tpr->rx_std_mapping); + tpr->rx_std = dma_alloc_coherent(&tp->pdev->dev, + TG3_RX_STD_RING_BYTES(tp), + &tpr->rx_std_mapping, + GFP_KERNEL); if (!tpr->rx_std) goto err_out; @@ -6370,9 +6372,10 @@ static int tg3_rx_prodring_init(struct tg3 *tp, if (!tpr->rx_jmb_buffers) goto err_out; - tpr->rx_jmb = pci_alloc_consistent(tp->pdev, - TG3_RX_JMB_RING_BYTES(tp), - &tpr->rx_jmb_mapping); + tpr->rx_jmb = dma_alloc_coherent(&tp->pdev->dev, + TG3_RX_JMB_RING_BYTES(tp), + &tpr->rx_jmb_mapping, + GFP_KERNEL); if (!tpr->rx_jmb) goto err_out; } @@ -6491,7 +6494,7 @@ static void tg3_free_consistent(struct tg3 *tp) struct tg3_napi *tnapi = &tp->napi[i]; if (tnapi->tx_ring) { - pci_free_consistent(tp->pdev, TG3_TX_RING_BYTES, + dma_free_coherent(&tp->pdev->dev, TG3_TX_RING_BYTES, tnapi->tx_ring, tnapi->tx_desc_mapping); tnapi->tx_ring = NULL; } @@ -6500,25 +6503,26 @@ static void tg3_free_consistent(struct tg3 *tp) tnapi->tx_buffers = NULL; if (tnapi->rx_rcb) { - pci_free_consistent(tp->pdev, TG3_RX_RCB_RING_BYTES(tp), - tnapi->rx_rcb, - tnapi->rx_rcb_mapping); + dma_free_coherent(&tp->pdev->dev, + TG3_RX_RCB_RING_BYTES(tp), + tnapi->rx_rcb, + tnapi->rx_rcb_mapping); tnapi->rx_rcb = NULL; } tg3_rx_prodring_fini(tp, &tnapi->prodring); if (tnapi->hw_status) { - pci_free_consistent(tp->pdev, TG3_HW_STATUS_SIZE, - tnapi->hw_status, - tnapi->status_mapping); + dma_free_coherent(&tp->pdev->dev, TG3_HW_STATUS_SIZE, + tnapi->hw_status, + tnapi->status_mapping); tnapi->hw_status = NULL; } } if (tp->hw_stats) { - pci_free_consistent(tp->pdev, sizeof(struct tg3_hw_stats), - tp->hw_stats, tp->stats_mapping); + dma_free_coherent(&tp->pdev->dev, sizeof(struct tg3_hw_stats), + tp->hw_stats, tp->stats_mapping); tp->hw_stats = NULL; } } @@ -6531,9 +6535,10 @@ static int tg3_alloc_consistent(struct tg3 *tp) { int i; - tp->hw_stats = pci_alloc_consistent(tp->pdev, - sizeof(struct tg3_hw_stats), - &tp->stats_mapping); + tp->hw_stats = dma_alloc_coherent(&tp->pdev->dev, + sizeof(struct tg3_hw_stats), + &tp->stats_mapping, + GFP_KERNEL); if (!tp->hw_stats) goto err_out; @@ -6543,9 +6548,10 @@ static int tg3_alloc_consistent(struct tg3 *tp) struct tg3_napi *tnapi = &tp->napi[i]; struct tg3_hw_status *sblk; - tnapi->hw_status = pci_alloc_consistent(tp->pdev, - TG3_HW_STATUS_SIZE, - &tnapi->status_mapping); + tnapi->hw_status = dma_alloc_coherent(&tp->pdev->dev, + TG3_HW_STATUS_SIZE, + &tnapi->status_mapping, + GFP_KERNEL); if (!tnapi->hw_status) goto err_out; @@ -6566,9 +6572,10 @@ static int tg3_alloc_consistent(struct tg3 *tp) if (!tnapi->tx_buffers) goto err_out; - tnapi->tx_ring = pci_alloc_consistent(tp->pdev, - TG3_TX_RING_BYTES, - &tnapi->tx_desc_mapping); + tnapi->tx_ring = dma_alloc_coherent(&tp->pdev->dev, + TG3_TX_RING_BYTES, + &tnapi->tx_desc_mapping, + GFP_KERNEL); if (!tnapi->tx_ring) goto err_out; } @@ -6601,9 +6608,10 @@ static int tg3_alloc_consistent(struct tg3 *tp) if (!i && (tp->tg3_flags3 & TG3_FLG3_ENABLE_RSS)) continue; - tnapi->rx_rcb = pci_alloc_consistent(tp->pdev, - TG3_RX_RCB_RING_BYTES(tp), - &tnapi->rx_rcb_mapping); + tnapi->rx_rcb = dma_alloc_coherent(&tp->pdev->dev, + TG3_RX_RCB_RING_BYTES(tp), + &tnapi->rx_rcb_mapping, + GFP_KERNEL); if (!tnapi->rx_rcb) goto err_out; @@ -14159,7 +14167,8 @@ static int __devinit tg3_test_dma(struct tg3 *tp) u32 *buf, saved_dma_rwctrl; int ret = 0; - buf = pci_alloc_consistent(tp->pdev, TEST_BUFFER_SIZE, &buf_dma); + buf = dma_alloc_coherent(&tp->pdev->dev, TEST_BUFFER_SIZE, + &buf_dma, GFP_KERNEL); if (!buf) { ret = -ENOMEM; goto out_nofree; @@ -14343,7 +14352,7 @@ static int __devinit tg3_test_dma(struct tg3 *tp) } out: - pci_free_consistent(tp->pdev, TEST_BUFFER_SIZE, buf, buf_dma); + dma_free_coherent(&tp->pdev->dev, TEST_BUFFER_SIZE, buf, buf_dma); out_nofree: return ret; } ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH net-next-2.6] tg3: use dma_alloc_coherent() instead of pci_alloc_consistent() 2010-10-26 12:03 ` [PATCH net-next-2.6] tg3: use dma_alloc_coherent() instead of pci_alloc_consistent() Eric Dumazet @ 2010-10-26 17:04 ` Matt Carlson 0 siblings, 0 replies; 12+ messages in thread From: Matt Carlson @ 2010-10-26 17:04 UTC (permalink / raw) To: Eric Dumazet Cc: Amit Salecha, Matthew Carlson, davem@davemloft.net, netdev@vger.kernel.org, Ameen Rahman, Anirban Chakraborty, Michael Chan On Tue, Oct 26, 2010 at 05:03:13AM -0700, Eric Dumazet wrote: > Le mardi 26 octobre 2010 ?? 12:30 +0200, Eric Dumazet a ??crit : > > > By the way, you should use dma_alloc_coherent() instead of > > pci_alloc_consistent() so that you can use GFP_KERNEL allocations > > instead of GFP_ATOMIC, it might help in low memory conditions (if you > > dont hold a spinlock at this point) > > > > tg3 being often used as a reference network driver, I believe we should > change its allocations before too many people copy paste suboptimal > pci_alloc_consistent() stuff... > > Matt, could you please queue this patch and submit it to David when > net-next-2.6 reopens ? Sure. Thanks for the patch. > Thanks > > [PATCH] tg3: use dma_alloc_coherent() instead of pci_alloc_consistent() > > Using dma_alloc_coherent() permits to use GFP_KERNEL allocations instead > of GFP_ATOMIC ones. Its better when a machine is out of memory, because > this allows driver to sleep to get its memory and succeed its init, > especially when allocating high order pages. > > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> > CC: Matt Carlson <mcarlson@broadcom.com> > CC: Michael Chan <mchan@broadcom.com> > --- > drivers/net/tg3.c | 73 ++++++++++++++++++++++++-------------------- > 1 file changed, 41 insertions(+), 32 deletions(-) > > diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c > index 852e917..7dfa579 100644 > --- a/drivers/net/tg3.c > +++ b/drivers/net/tg3.c > @@ -6339,13 +6339,13 @@ static void tg3_rx_prodring_fini(struct tg3 *tp, > kfree(tpr->rx_jmb_buffers); > tpr->rx_jmb_buffers = NULL; > if (tpr->rx_std) { > - pci_free_consistent(tp->pdev, TG3_RX_STD_RING_BYTES(tp), > - tpr->rx_std, tpr->rx_std_mapping); > + dma_free_coherent(&tp->pdev->dev, TG3_RX_STD_RING_BYTES(tp), > + tpr->rx_std, tpr->rx_std_mapping); > tpr->rx_std = NULL; > } > if (tpr->rx_jmb) { > - pci_free_consistent(tp->pdev, TG3_RX_JMB_RING_BYTES(tp), > - tpr->rx_jmb, tpr->rx_jmb_mapping); > + dma_free_coherent(&tp->pdev->dev, TG3_RX_JMB_RING_BYTES(tp), > + tpr->rx_jmb, tpr->rx_jmb_mapping); > tpr->rx_jmb = NULL; > } > } > @@ -6358,8 +6358,10 @@ static int tg3_rx_prodring_init(struct tg3 *tp, > if (!tpr->rx_std_buffers) > return -ENOMEM; > > - tpr->rx_std = pci_alloc_consistent(tp->pdev, TG3_RX_STD_RING_BYTES(tp), > - &tpr->rx_std_mapping); > + tpr->rx_std = dma_alloc_coherent(&tp->pdev->dev, > + TG3_RX_STD_RING_BYTES(tp), > + &tpr->rx_std_mapping, > + GFP_KERNEL); > if (!tpr->rx_std) > goto err_out; > > @@ -6370,9 +6372,10 @@ static int tg3_rx_prodring_init(struct tg3 *tp, > if (!tpr->rx_jmb_buffers) > goto err_out; > > - tpr->rx_jmb = pci_alloc_consistent(tp->pdev, > - TG3_RX_JMB_RING_BYTES(tp), > - &tpr->rx_jmb_mapping); > + tpr->rx_jmb = dma_alloc_coherent(&tp->pdev->dev, > + TG3_RX_JMB_RING_BYTES(tp), > + &tpr->rx_jmb_mapping, > + GFP_KERNEL); > if (!tpr->rx_jmb) > goto err_out; > } > @@ -6491,7 +6494,7 @@ static void tg3_free_consistent(struct tg3 *tp) > struct tg3_napi *tnapi = &tp->napi[i]; > > if (tnapi->tx_ring) { > - pci_free_consistent(tp->pdev, TG3_TX_RING_BYTES, > + dma_free_coherent(&tp->pdev->dev, TG3_TX_RING_BYTES, > tnapi->tx_ring, tnapi->tx_desc_mapping); > tnapi->tx_ring = NULL; > } > @@ -6500,25 +6503,26 @@ static void tg3_free_consistent(struct tg3 *tp) > tnapi->tx_buffers = NULL; > > if (tnapi->rx_rcb) { > - pci_free_consistent(tp->pdev, TG3_RX_RCB_RING_BYTES(tp), > - tnapi->rx_rcb, > - tnapi->rx_rcb_mapping); > + dma_free_coherent(&tp->pdev->dev, > + TG3_RX_RCB_RING_BYTES(tp), > + tnapi->rx_rcb, > + tnapi->rx_rcb_mapping); > tnapi->rx_rcb = NULL; > } > > tg3_rx_prodring_fini(tp, &tnapi->prodring); > > if (tnapi->hw_status) { > - pci_free_consistent(tp->pdev, TG3_HW_STATUS_SIZE, > - tnapi->hw_status, > - tnapi->status_mapping); > + dma_free_coherent(&tp->pdev->dev, TG3_HW_STATUS_SIZE, > + tnapi->hw_status, > + tnapi->status_mapping); > tnapi->hw_status = NULL; > } > } > > if (tp->hw_stats) { > - pci_free_consistent(tp->pdev, sizeof(struct tg3_hw_stats), > - tp->hw_stats, tp->stats_mapping); > + dma_free_coherent(&tp->pdev->dev, sizeof(struct tg3_hw_stats), > + tp->hw_stats, tp->stats_mapping); > tp->hw_stats = NULL; > } > } > @@ -6531,9 +6535,10 @@ static int tg3_alloc_consistent(struct tg3 *tp) > { > int i; > > - tp->hw_stats = pci_alloc_consistent(tp->pdev, > - sizeof(struct tg3_hw_stats), > - &tp->stats_mapping); > + tp->hw_stats = dma_alloc_coherent(&tp->pdev->dev, > + sizeof(struct tg3_hw_stats), > + &tp->stats_mapping, > + GFP_KERNEL); > if (!tp->hw_stats) > goto err_out; > > @@ -6543,9 +6548,10 @@ static int tg3_alloc_consistent(struct tg3 *tp) > struct tg3_napi *tnapi = &tp->napi[i]; > struct tg3_hw_status *sblk; > > - tnapi->hw_status = pci_alloc_consistent(tp->pdev, > - TG3_HW_STATUS_SIZE, > - &tnapi->status_mapping); > + tnapi->hw_status = dma_alloc_coherent(&tp->pdev->dev, > + TG3_HW_STATUS_SIZE, > + &tnapi->status_mapping, > + GFP_KERNEL); > if (!tnapi->hw_status) > goto err_out; > > @@ -6566,9 +6572,10 @@ static int tg3_alloc_consistent(struct tg3 *tp) > if (!tnapi->tx_buffers) > goto err_out; > > - tnapi->tx_ring = pci_alloc_consistent(tp->pdev, > - TG3_TX_RING_BYTES, > - &tnapi->tx_desc_mapping); > + tnapi->tx_ring = dma_alloc_coherent(&tp->pdev->dev, > + TG3_TX_RING_BYTES, > + &tnapi->tx_desc_mapping, > + GFP_KERNEL); > if (!tnapi->tx_ring) > goto err_out; > } > @@ -6601,9 +6608,10 @@ static int tg3_alloc_consistent(struct tg3 *tp) > if (!i && (tp->tg3_flags3 & TG3_FLG3_ENABLE_RSS)) > continue; > > - tnapi->rx_rcb = pci_alloc_consistent(tp->pdev, > - TG3_RX_RCB_RING_BYTES(tp), > - &tnapi->rx_rcb_mapping); > + tnapi->rx_rcb = dma_alloc_coherent(&tp->pdev->dev, > + TG3_RX_RCB_RING_BYTES(tp), > + &tnapi->rx_rcb_mapping, > + GFP_KERNEL); > if (!tnapi->rx_rcb) > goto err_out; > > @@ -14159,7 +14167,8 @@ static int __devinit tg3_test_dma(struct tg3 *tp) > u32 *buf, saved_dma_rwctrl; > int ret = 0; > > - buf = pci_alloc_consistent(tp->pdev, TEST_BUFFER_SIZE, &buf_dma); > + buf = dma_alloc_coherent(&tp->pdev->dev, TEST_BUFFER_SIZE, > + &buf_dma, GFP_KERNEL); > if (!buf) { > ret = -ENOMEM; > goto out_nofree; > @@ -14343,7 +14352,7 @@ static int __devinit tg3_test_dma(struct tg3 *tp) > } > > out: > - pci_free_consistent(tp->pdev, TEST_BUFFER_SIZE, buf, buf_dma); > + dma_free_coherent(&tp->pdev->dev, TEST_BUFFER_SIZE, buf, buf_dma); > out_nofree: > return ret; > } > > > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4]qlcnic: bug fixes 2010-10-26 9:37 [PATCH 0/4]qlcnic: bug fixes Amit Kumar Salecha ` (3 preceding siblings ...) 2010-10-26 9:38 ` [PATCH] qlcnic: dma address align check Amit Kumar Salecha @ 2010-10-26 15:37 ` David Miller 4 siblings, 0 replies; 12+ messages in thread From: David Miller @ 2010-10-26 15:37 UTC (permalink / raw) To: amit.salecha; +Cc: netdev, ameen.rahman, anirban.chakraborty From: Amit Kumar Salecha <amit.salecha@qlogic.com> Date: Tue, 26 Oct 2010 02:37:58 -0700 > Hi > Series of 4 bug fixes. Apply them on net-2.6 branch. Your patches weren't numbered, making the order I should apply them ambiguous. Please fix the subject lines and resubmit. Thank you. ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2010-10-26 17:04 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-10-26 9:37 [PATCH 0/4]qlcnic: bug fixes Amit Kumar Salecha 2010-10-26 9:37 ` [PATCH] qlcnic: fix mac learning Amit Kumar Salecha 2010-10-26 9:38 ` [PATCH] qlcnic: reduce RX ring size for nic partition Amit Kumar Salecha 2010-10-26 9:38 ` [PATCH] qlcnic: define valid vlan id range Amit Kumar Salecha 2010-10-26 9:38 ` [PATCH] qlcnic: dma address align check Amit Kumar Salecha 2010-10-26 9:54 ` Eric Dumazet 2010-10-26 10:04 ` Amit Salecha 2010-10-26 10:30 ` Eric Dumazet 2010-10-26 10:52 ` Amit Salecha 2010-10-26 12:03 ` [PATCH net-next-2.6] tg3: use dma_alloc_coherent() instead of pci_alloc_consistent() Eric Dumazet 2010-10-26 17:04 ` Matt Carlson 2010-10-26 15:37 ` [PATCH 0/4]qlcnic: bug fixes David Miller
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).