* [PATCH net-next 1/6] bnx2: Add bnx2_shutdown_chip().
@ 2008-10-09 17:16 Michael Chan
2008-10-09 17:16 ` [PATCH net-next 2/6] bnx2: Check netif_running() in all ethtool operations Michael Chan
` (5 more replies)
0 siblings, 6 replies; 14+ messages in thread
From: Michael Chan @ 2008-10-09 17:16 UTC (permalink / raw)
To: davem; +Cc: netdev, Michael Chan, Benjamin Li, Matt Carlson
This logic is used in bnx2_close() and bnx2_suspend() and
so should be separated out into a separate function.
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: Benjamin Li <benli@broadcom.com>
Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
---
drivers/net/bnx2.c | 33 +++++++++++++++++----------------
1 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 883e0a7..b35f440 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -5073,6 +5073,21 @@ bnx2_init_nic(struct bnx2 *bp, int reset_phy)
}
static int
+bnx2_shutdown_chip(struct bnx2 *bp)
+{
+ u32 reset_code;
+
+ if (bp->flags & BNX2_FLAG_NO_WOL)
+ reset_code = BNX2_DRV_MSG_CODE_UNLOAD_LNK_DN;
+ else if (bp->wol)
+ reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL;
+ else
+ reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
+
+ return bnx2_reset_chip(bp, reset_code);
+}
+
+static int
bnx2_test_registers(struct bnx2 *bp)
{
int ret;
@@ -6095,20 +6110,13 @@ static int
bnx2_close(struct net_device *dev)
{
struct bnx2 *bp = netdev_priv(dev);
- u32 reset_code;
cancel_work_sync(&bp->reset_task);
bnx2_disable_int_sync(bp);
bnx2_napi_disable(bp);
del_timer_sync(&bp->timer);
- if (bp->flags & BNX2_FLAG_NO_WOL)
- reset_code = BNX2_DRV_MSG_CODE_UNLOAD_LNK_DN;
- else if (bp->wol)
- reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL;
- else
- reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
- bnx2_reset_chip(bp, reset_code);
+ bnx2_shutdown_chip(bp);
bnx2_free_irq(bp);
bnx2_free_skbs(bp);
bnx2_free_mem(bp);
@@ -7777,7 +7785,6 @@ bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
{
struct net_device *dev = pci_get_drvdata(pdev);
struct bnx2 *bp = netdev_priv(dev);
- u32 reset_code;
/* PCI register 4 needs to be saved whether netif_running() or not.
* MSI address and data need to be saved if using MSI and
@@ -7791,13 +7798,7 @@ bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
bnx2_netif_stop(bp);
netif_device_detach(dev);
del_timer_sync(&bp->timer);
- if (bp->flags & BNX2_FLAG_NO_WOL)
- reset_code = BNX2_DRV_MSG_CODE_UNLOAD_LNK_DN;
- else if (bp->wol)
- reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL;
- else
- reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
- bnx2_reset_chip(bp, reset_code);
+ bnx2_shutdown_chip(bp);
bnx2_free_skbs(bp);
bnx2_set_power_state(bp, pci_choose_state(pdev, state));
return 0;
--
1.5.6.GIT
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH net-next 2/6] bnx2: Check netif_running() in all ethtool operations. 2008-10-09 17:16 [PATCH net-next 1/6] bnx2: Add bnx2_shutdown_chip() Michael Chan @ 2008-10-09 17:16 ` Michael Chan 2008-10-09 19:22 ` David Miller 2008-10-09 17:16 ` [PATCH net-next 4/6] bnx2: Eliminate TSO header modifications Michael Chan ` (4 subsequent siblings) 5 siblings, 1 reply; 14+ messages in thread From: Michael Chan @ 2008-10-09 17:16 UTC (permalink / raw) To: davem; +Cc: netdev, Michael Chan, Benjamin Li, Matt Carlson We need to check netif_running() state in most ethtool operations and properly handle the !netif_running() state where the chip is in an uninitailzed state or low power state that may not accept any MMIO. Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: Benjamin Li <benli@broadcom.com> Signed-off-by: Matt Carlson <mcarlson@broadcom.com> --- drivers/net/bnx2.c | 40 ++++++++++++++++++++++++++++++++-------- 1 files changed, 32 insertions(+), 8 deletions(-) diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index b35f440..21711c7 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c @@ -3248,6 +3248,9 @@ bnx2_set_rx_mode(struct net_device *dev) struct dev_addr_list *uc_ptr; int i; + if (!netif_running(dev)) + return; + spin_lock_bh(&bp->phy_lock); rx_mode = bp->rx_mode & ~(BNX2_EMAC_RX_MODE_PROMISCUOUS | @@ -5521,6 +5524,9 @@ bnx2_test_link(struct bnx2 *bp) { u32 bmsr; + if (!netif_running(bp->dev)) + return -ENODEV; + if (bp->phy_flags & BNX2_PHY_FLAG_REMOTE_PHY_CAP) { if (bp->link_up) return 0; @@ -6485,6 +6491,9 @@ bnx2_nway_reset(struct net_device *dev) struct bnx2 *bp = netdev_priv(dev); u32 bmcr; + if (!netif_running(dev)) + return -EAGAIN; + if (!(bp->autoneg & AUTONEG_SPEED)) { return -EINVAL; } @@ -6540,6 +6549,9 @@ bnx2_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, struct bnx2 *bp = netdev_priv(dev); int rc; + if (!netif_running(dev)) + return -EAGAIN; + /* parameters already validated in ethtool_get_eeprom */ rc = bnx2_nvram_read(bp, eeprom->offset, eebuf, eeprom->len); @@ -6554,6 +6566,9 @@ bnx2_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, struct bnx2 *bp = netdev_priv(dev); int rc; + if (!netif_running(dev)) + return -EAGAIN; + /* parameters already validated in ethtool_set_eeprom */ rc = bnx2_nvram_write(bp, eeprom->offset, eebuf, eeprom->len); @@ -6718,11 +6733,11 @@ bnx2_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause) bp->autoneg &= ~AUTONEG_FLOW_CTRL; } - spin_lock_bh(&bp->phy_lock); - - bnx2_setup_phy(bp, bp->phy_port); - - spin_unlock_bh(&bp->phy_lock); + if (netif_running(dev)) { + spin_lock_bh(&bp->phy_lock); + bnx2_setup_phy(bp, bp->phy_port); + spin_unlock_bh(&bp->phy_lock); + } return 0; } @@ -6913,6 +6928,8 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf) { struct bnx2 *bp = netdev_priv(dev); + bnx2_set_power_state(bp, PCI_D0); + memset(buf, 0, sizeof(u64) * BNX2_NUM_TESTS); if (etest->flags & ETH_TEST_FL_OFFLINE) { int i; @@ -6932,9 +6949,8 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf) if ((buf[2] = bnx2_test_loopback(bp)) != 0) etest->flags |= ETH_TEST_FL_FAILED; - if (!netif_running(bp->dev)) { - bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET); - } + if (!netif_running(bp->dev)) + bnx2_shutdown_chip(bp); else { bnx2_init_nic(bp, 1); bnx2_netif_start(bp); @@ -6962,6 +6978,8 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf) etest->flags |= ETH_TEST_FL_FAILED; } + if (!netif_running(bp->dev)) + bnx2_set_power_state(bp, PCI_D3hot); } static void @@ -7027,6 +7045,8 @@ bnx2_phys_id(struct net_device *dev, u32 data) int i; u32 save; + bnx2_set_power_state(bp, PCI_D0); + if (data == 0) data = 2; @@ -7051,6 +7071,10 @@ bnx2_phys_id(struct net_device *dev, u32 data) } REG_WR(bp, BNX2_EMAC_LED, 0); REG_WR(bp, BNX2_MISC_CFG, save); + + if (!netif_running(dev)) + bnx2_set_power_state(bp, PCI_D3hot); + return 0; } -- 1.5.6.GIT ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH net-next 2/6] bnx2: Check netif_running() in all ethtool operations. 2008-10-09 17:16 ` [PATCH net-next 2/6] bnx2: Check netif_running() in all ethtool operations Michael Chan @ 2008-10-09 19:22 ` David Miller 2008-10-09 20:59 ` Michael Chan 0 siblings, 1 reply; 14+ messages in thread From: David Miller @ 2008-10-09 19:22 UTC (permalink / raw) To: mchan; +Cc: netdev, benli, mcarlson From: "Michael Chan" <mchan@broadcom.com> Date: Thu, 9 Oct 2008 10:16:04 -0700 > We need to check netif_running() state in most ethtool operations > and properly handle the !netif_running() state where the chip is > in an uninitailzed state or low power state that may not accept > any MMIO. > > Signed-off-by: Michael Chan <mchan@broadcom.com> > Signed-off-by: Benjamin Li <benli@broadcom.com> > Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Applied, but I wonder if this will trip people up who invoke ethtool to set a specific link setting before bringing the device up? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH net-next 2/6] bnx2: Check netif_running() in all ethtool operations. 2008-10-09 19:22 ` David Miller @ 2008-10-09 20:59 ` Michael Chan 2008-10-09 21:26 ` David Miller 0 siblings, 1 reply; 14+ messages in thread From: Michael Chan @ 2008-10-09 20:59 UTC (permalink / raw) To: David Miller; +Cc: netdev@vger.kernel.org, Benjamin Li, Matthew Carlson On Thu, 2008-10-09 at 12:22 -0700, David Miller wrote: > From: "Michael Chan" <mchan@broadcom.com> > Date: Thu, 9 Oct 2008 10:16:04 -0700 > > > We need to check netif_running() state in most ethtool operations > > and properly handle the !netif_running() state where the chip is > > in an uninitailzed state or low power state that may not accept > > any MMIO. > > > > Signed-off-by: Michael Chan <mchan@broadcom.com> > > Signed-off-by: Benjamin Li <benli@broadcom.com> > > Signed-off-by: Matt Carlson <mcarlson@broadcom.com> > > Applied, but I wonder if this will trip people up who invoke > ethtool to set a specific link setting before bringing the > device up? > ethtool -s is not affected by the patch and will continue to work whether the device is up or down. The patch affects operations such as reading/writing NVRAM, restart autoneg, etc, that require the device to be up. Thanks. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH net-next 2/6] bnx2: Check netif_running() in all ethtool operations. 2008-10-09 20:59 ` Michael Chan @ 2008-10-09 21:26 ` David Miller 0 siblings, 0 replies; 14+ messages in thread From: David Miller @ 2008-10-09 21:26 UTC (permalink / raw) To: mchan; +Cc: netdev, benli, mcarlson From: "Michael Chan" <mchan@broadcom.com> Date: Thu, 09 Oct 2008 13:59:00 -0700 > > On Thu, 2008-10-09 at 12:22 -0700, David Miller wrote: > > From: "Michael Chan" <mchan@broadcom.com> > > Date: Thu, 9 Oct 2008 10:16:04 -0700 > > > > > We need to check netif_running() state in most ethtool operations > > > and properly handle the !netif_running() state where the chip is > > > in an uninitailzed state or low power state that may not accept > > > any MMIO. > > > > > > Signed-off-by: Michael Chan <mchan@broadcom.com> > > > Signed-off-by: Benjamin Li <benli@broadcom.com> > > > Signed-off-by: Matt Carlson <mcarlson@broadcom.com> > > > > Applied, but I wonder if this will trip people up who invoke > > ethtool to set a specific link setting before bringing the > > device up? > > > > ethtool -s is not affected by the patch and will continue to work > whether the device is up or down. The patch affects operations such as > reading/writing NVRAM, restart autoneg, etc, that require the device to > be up. Thanks for the clarification. ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH net-next 4/6] bnx2: Eliminate TSO header modifications. 2008-10-09 17:16 [PATCH net-next 1/6] bnx2: Add bnx2_shutdown_chip() Michael Chan 2008-10-09 17:16 ` [PATCH net-next 2/6] bnx2: Check netif_running() in all ethtool operations Michael Chan @ 2008-10-09 17:16 ` Michael Chan 2008-10-09 19:25 ` David Miller 2008-10-09 17:16 ` [PATCH net-next 5/6] bnx2: Handle DMA mapping errors Michael Chan ` (3 subsequent siblings) 5 siblings, 1 reply; 14+ messages in thread From: Michael Chan @ 2008-10-09 17:16 UTC (permalink / raw) To: davem; +Cc: netdev, Michael Chan This is now possible with updated firmware. Signed-off-by: Michael Chan <mchan@broadcom.com> --- drivers/net/bnx2.c | 16 +--------------- 1 files changed, 1 insertions(+), 15 deletions(-) diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index 21711c7..f147204 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c @@ -6008,7 +6008,7 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev) } #endif if ((mss = skb_shinfo(skb)->gso_size)) { - u32 tcp_opt_len, ip_tcp_len; + u32 tcp_opt_len; struct iphdr *iph; vlan_tag_flags |= TX_BD_FLAGS_SW_LSO; @@ -6032,21 +6032,7 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev) mss |= (tcp_off & 0xc) << TX_BD_TCP6_OFF2_SHL; } } else { - if (skb_header_cloned(skb) && - pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) { - dev_kfree_skb(skb); - return NETDEV_TX_OK; - } - - ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr); - iph = ip_hdr(skb); - iph->check = 0; - iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len); - tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, - iph->daddr, 0, - IPPROTO_TCP, - 0); if (tcp_opt_len || (iph->ihl > 5)) { vlan_tag_flags |= ((iph->ihl - 5) + (tcp_opt_len >> 2)) << 8; -- 1.5.6.GIT ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH net-next 4/6] bnx2: Eliminate TSO header modifications. 2008-10-09 17:16 ` [PATCH net-next 4/6] bnx2: Eliminate TSO header modifications Michael Chan @ 2008-10-09 19:25 ` David Miller 2008-10-09 20:56 ` Michael Chan 0 siblings, 1 reply; 14+ messages in thread From: David Miller @ 2008-10-09 19:25 UTC (permalink / raw) To: mchan; +Cc: netdev From: "Michael Chan" <mchan@broadcom.com> Date: Thu, 9 Oct 2008 10:16:06 -0700 > This is now possible with updated firmware. > > Signed-off-by: Michael Chan <mchan@broadcom.com> Nice, applied. Quick question, in the intermediate step where we have the new firmware (patch #3) but not this change applied (patch #4) does TSO still work properly? If TSO is bolixed after patch #3 but before patch #4 please don't create those kinds of non-bisectable situations in the future. I'd rather you do the firmware update and the TSO logic changes all in one go to keep it all working. Thanks! ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH net-next 4/6] bnx2: Eliminate TSO header modifications. 2008-10-09 19:25 ` David Miller @ 2008-10-09 20:56 ` Michael Chan 0 siblings, 0 replies; 14+ messages in thread From: Michael Chan @ 2008-10-09 20:56 UTC (permalink / raw) To: David Miller; +Cc: netdev@vger.kernel.org On Thu, 2008-10-09 at 12:25 -0700, David Miller wrote: > From: "Michael Chan" <mchan@broadcom.com> > Date: Thu, 9 Oct 2008 10:16:06 -0700 > > > This is now possible with updated firmware. > > > > Signed-off-by: Michael Chan <mchan@broadcom.com> > > Nice, applied. > > Quick question, in the intermediate step where we have the > new firmware (patch #3) but not this change applied (patch > #4) does TSO still work properly? It will still work. The firmware will overwrite the header fields modified (unnecessarily) by the driver. > > If TSO is bolixed after patch #3 but before patch #4 please > don't create those kinds of non-bisectable situations in > the future. I'd rather you do the firmware update and the > TSO logic changes all in one go to keep it all working. > > Thanks! > ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH net-next 5/6] bnx2: Handle DMA mapping errors. 2008-10-09 17:16 [PATCH net-next 1/6] bnx2: Add bnx2_shutdown_chip() Michael Chan 2008-10-09 17:16 ` [PATCH net-next 2/6] bnx2: Check netif_running() in all ethtool operations Michael Chan 2008-10-09 17:16 ` [PATCH net-next 4/6] bnx2: Eliminate TSO header modifications Michael Chan @ 2008-10-09 17:16 ` Michael Chan 2008-10-09 19:26 ` David Miller 2008-10-09 17:16 ` [PATCH net-next 6/6] bnx2: Update version to 1.8.1 Michael Chan ` (2 subsequent siblings) 5 siblings, 1 reply; 14+ messages in thread From: Michael Chan @ 2008-10-09 17:16 UTC (permalink / raw) To: davem; +Cc: netdev, Michael Chan, Benjamin Li Before, the driver would not care about the return codes from pci_map_* functions. This could be potentially dangerous if a mapping failed. Now, we will check all pci_map_* calls. On the transmit side, we switch to use the new function skb_dma_map(). On the receive side, we add pci_dma_mapping_error(). Signed-off-by: Benjamin Li <benli@broadcom.com> Signed-off-by: Michael Chan <mchan@broadcom.com> --- drivers/net/bnx2.c | 114 ++++++++++++++++++++++++++++------------------------ drivers/net/bnx2.h | 8 +++- 2 files changed, 67 insertions(+), 55 deletions(-) diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index f147204..a95ca4f 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c @@ -2476,6 +2476,11 @@ bnx2_alloc_rx_page(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, u16 index) return -ENOMEM; mapping = pci_map_page(bp->pdev, page, 0, PAGE_SIZE, PCI_DMA_FROMDEVICE); + if (pci_dma_mapping_error(bp->pdev, mapping)) { + __free_page(page); + return -EIO; + } + rx_pg->page = page; pci_unmap_addr_set(rx_pg, mapping, mapping); rxbd->rx_bd_haddr_hi = (u64) mapping >> 32; @@ -2518,6 +2523,10 @@ bnx2_alloc_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, u16 index) mapping = pci_map_single(bp->pdev, skb->data, bp->rx_buf_use_size, PCI_DMA_FROMDEVICE); + if (pci_dma_mapping_error(bp->pdev, mapping)) { + dev_kfree_skb(skb); + return -EIO; + } rx_buf->skb = skb; pci_unmap_addr_set(rx_buf, mapping, mapping); @@ -2592,7 +2601,7 @@ bnx2_tx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget) sw_cons = txr->tx_cons; while (sw_cons != hw_cons) { - struct sw_bd *tx_buf; + struct sw_tx_bd *tx_buf; struct sk_buff *skb; int i, last; @@ -2617,21 +2626,13 @@ bnx2_tx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget) } } - pci_unmap_single(bp->pdev, pci_unmap_addr(tx_buf, mapping), - skb_headlen(skb), PCI_DMA_TODEVICE); + skb_dma_unmap(&bp->pdev->dev, skb, DMA_TO_DEVICE); tx_buf->skb = NULL; last = skb_shinfo(skb)->nr_frags; for (i = 0; i < last; i++) { sw_cons = NEXT_TX_BD(sw_cons); - - pci_unmap_page(bp->pdev, - pci_unmap_addr( - &txr->tx_buf_ring[TX_RING_IDX(sw_cons)], - mapping), - skb_shinfo(skb)->frags[i].size, - PCI_DMA_TODEVICE); } sw_cons = NEXT_TX_BD(sw_cons); @@ -2672,11 +2673,31 @@ bnx2_reuse_rx_skb_pages(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, { struct sw_pg *cons_rx_pg, *prod_rx_pg; struct rx_bd *cons_bd, *prod_bd; - dma_addr_t mapping; int i; - u16 hw_prod = rxr->rx_pg_prod, prod; + u16 hw_prod, prod; u16 cons = rxr->rx_pg_cons; + cons_rx_pg = &rxr->rx_pg_ring[cons]; + + /* The caller was unable to allocate a new page to replace the + * last one in the frags array, so we need to recycle that page + * and then free the skb. + */ + if (skb) { + struct page *page; + struct skb_shared_info *shinfo; + + shinfo = skb_shinfo(skb); + shinfo->nr_frags--; + page = shinfo->frags[shinfo->nr_frags].page; + shinfo->frags[shinfo->nr_frags].page = NULL; + + cons_rx_pg->page = page; + dev_kfree_skb(skb); + } + + hw_prod = rxr->rx_pg_prod; + for (i = 0; i < count; i++) { prod = RX_PG_RING_IDX(hw_prod); @@ -2685,20 +2706,6 @@ bnx2_reuse_rx_skb_pages(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, cons_bd = &rxr->rx_pg_desc_ring[RX_RING(cons)][RX_IDX(cons)]; prod_bd = &rxr->rx_pg_desc_ring[RX_RING(prod)][RX_IDX(prod)]; - if (i == 0 && skb) { - struct page *page; - struct skb_shared_info *shinfo; - - shinfo = skb_shinfo(skb); - shinfo->nr_frags--; - page = shinfo->frags[shinfo->nr_frags].page; - shinfo->frags[shinfo->nr_frags].page = NULL; - mapping = pci_map_page(bp->pdev, page, 0, PAGE_SIZE, - PCI_DMA_FROMDEVICE); - cons_rx_pg->page = page; - pci_unmap_addr_set(cons_rx_pg, mapping, mapping); - dev_kfree_skb(skb); - } if (prod != cons) { prod_rx_pg->page = cons_rx_pg->page; cons_rx_pg->page = NULL; @@ -2784,6 +2791,8 @@ bnx2_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, struct sk_buff *skb, skb_put(skb, hdr_len); for (i = 0; i < pages; i++) { + dma_addr_t mapping_old; + frag_len = min(frag_size, (unsigned int) PAGE_SIZE); if (unlikely(frag_len <= 4)) { unsigned int tail = 4 - frag_len; @@ -2806,9 +2815,10 @@ bnx2_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, struct sk_buff *skb, } rx_pg = &rxr->rx_pg_ring[pg_cons]; - pci_unmap_page(bp->pdev, pci_unmap_addr(rx_pg, mapping), - PAGE_SIZE, PCI_DMA_FROMDEVICE); - + /* Don't unmap yet. If we're unable to allocate a new + * page, we need to recycle the page and the DMA addr. + */ + mapping_old = pci_unmap_addr(rx_pg, mapping); if (i == pages - 1) frag_len -= 4; @@ -2825,6 +2835,9 @@ bnx2_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, struct sk_buff *skb, return err; } + pci_unmap_page(bp->pdev, mapping_old, + PAGE_SIZE, PCI_DMA_FROMDEVICE); + frag_size -= frag_len; skb->data_len += frag_len; skb->truesize += frag_len; @@ -4971,31 +4984,20 @@ bnx2_free_tx_skbs(struct bnx2 *bp) continue; for (j = 0; j < TX_DESC_CNT; ) { - struct sw_bd *tx_buf = &txr->tx_buf_ring[j]; + struct sw_tx_bd *tx_buf = &txr->tx_buf_ring[j]; struct sk_buff *skb = tx_buf->skb; - int k, last; if (skb == NULL) { j++; continue; } - pci_unmap_single(bp->pdev, - pci_unmap_addr(tx_buf, mapping), - skb_headlen(skb), PCI_DMA_TODEVICE); + skb_dma_unmap(&bp->pdev->dev, skb, DMA_TO_DEVICE); tx_buf->skb = NULL; - last = skb_shinfo(skb)->nr_frags; - for (k = 0; k < last; k++) { - tx_buf = &txr->tx_buf_ring[j + k + 1]; - pci_unmap_page(bp->pdev, - pci_unmap_addr(tx_buf, mapping), - skb_shinfo(skb)->frags[j].size, - PCI_DMA_TODEVICE); - } + j += skb_shinfo(skb)->nr_frags + 1; dev_kfree_skb(skb); - j += k + 1; } } } @@ -5373,8 +5375,11 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode) for (i = 14; i < pkt_size; i++) packet[i] = (unsigned char) (i & 0xff); - map = pci_map_single(bp->pdev, skb->data, pkt_size, - PCI_DMA_TODEVICE); + if (skb_dma_map(&bp->pdev->dev, skb, DMA_TO_DEVICE)) { + dev_kfree_skb(skb); + return -EIO; + } + map = skb_shinfo(skb)->dma_maps[0]; REG_WR(bp, BNX2_HC_COMMAND, bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW_WO_INT); @@ -5409,7 +5414,7 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode) udelay(5); - pci_unmap_single(bp->pdev, map, pkt_size, PCI_DMA_TODEVICE); + skb_dma_unmap(&bp->pdev->dev, skb, DMA_TO_DEVICE); dev_kfree_skb(skb); if (bnx2_get_hw_tx_cons(tx_napi) != txr->tx_prod) @@ -5970,13 +5975,14 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev) struct bnx2 *bp = netdev_priv(dev); dma_addr_t mapping; struct tx_bd *txbd; - struct sw_bd *tx_buf; + struct sw_tx_bd *tx_buf; u32 len, vlan_tag_flags, last_frag, mss; u16 prod, ring_prod; int i; struct bnx2_napi *bnapi; struct bnx2_tx_ring_info *txr; struct netdev_queue *txq; + struct skb_shared_info *sp; /* Determine which tx ring we will be placed on */ i = skb_get_queue_mapping(skb); @@ -6041,11 +6047,16 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev) } else mss = 0; - mapping = pci_map_single(bp->pdev, skb->data, len, PCI_DMA_TODEVICE); + if (skb_dma_map(&bp->pdev->dev, skb, DMA_TO_DEVICE)) { + dev_kfree_skb(skb); + return NETDEV_TX_OK; + } + + sp = skb_shinfo(skb); + mapping = sp->dma_maps[0]; tx_buf = &txr->tx_buf_ring[ring_prod]; tx_buf->skb = skb; - pci_unmap_addr_set(tx_buf, mapping, mapping); txbd = &txr->tx_desc_ring[ring_prod]; @@ -6064,10 +6075,7 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev) txbd = &txr->tx_desc_ring[ring_prod]; len = frag->size; - mapping = pci_map_page(bp->pdev, frag->page, frag->page_offset, - len, PCI_DMA_TODEVICE); - pci_unmap_addr_set(&txr->tx_buf_ring[ring_prod], - mapping, mapping); + mapping = sp->dma_maps[i + 1]; txbd->tx_bd_haddr_hi = (u64) mapping >> 32; txbd->tx_bd_haddr_lo = (u64) mapping & 0xffffffff; diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h index edc7774..617d953 100644 --- a/drivers/net/bnx2.h +++ b/drivers/net/bnx2.h @@ -6526,10 +6526,14 @@ struct sw_pg { DECLARE_PCI_UNMAP_ADDR(mapping) }; +struct sw_tx_bd { + struct sk_buff *skb; +}; + #define SW_RXBD_RING_SIZE (sizeof(struct sw_bd) * RX_DESC_CNT) #define SW_RXPG_RING_SIZE (sizeof(struct sw_pg) * RX_DESC_CNT) #define RXBD_RING_SIZE (sizeof(struct rx_bd) * RX_DESC_CNT) -#define SW_TXBD_RING_SIZE (sizeof(struct sw_bd) * TX_DESC_CNT) +#define SW_TXBD_RING_SIZE (sizeof(struct sw_tx_bd) * TX_DESC_CNT) #define TXBD_RING_SIZE (sizeof(struct tx_bd) * TX_DESC_CNT) /* Buffered flash (Atmel: AT45DB011B) specific information */ @@ -6609,7 +6613,7 @@ struct bnx2_tx_ring_info { u32 tx_bseq_addr; struct tx_bd *tx_desc_ring; - struct sw_bd *tx_buf_ring; + struct sw_tx_bd *tx_buf_ring; u16 tx_cons; u16 hw_tx_cons; -- 1.5.6.GIT ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH net-next 5/6] bnx2: Handle DMA mapping errors. 2008-10-09 17:16 ` [PATCH net-next 5/6] bnx2: Handle DMA mapping errors Michael Chan @ 2008-10-09 19:26 ` David Miller 0 siblings, 0 replies; 14+ messages in thread From: David Miller @ 2008-10-09 19:26 UTC (permalink / raw) To: mchan; +Cc: netdev, benli From: "Michael Chan" <mchan@broadcom.com> Date: Thu, 9 Oct 2008 10:16:07 -0700 > Before, the driver would not care about the return codes from pci_map_* > functions. This could be potentially dangerous if a mapping failed. > Now, we will check all pci_map_* calls. On the transmit side, we switch > to use the new function skb_dma_map(). On the receive side, we add > pci_dma_mapping_error(). > > Signed-off-by: Benjamin Li <benli@broadcom.com> > Signed-off-by: Michael Chan <mchan@broadcom.com> Applied, thanks. ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH net-next 6/6] bnx2: Update version to 1.8.1. 2008-10-09 17:16 [PATCH net-next 1/6] bnx2: Add bnx2_shutdown_chip() Michael Chan ` (2 preceding siblings ...) 2008-10-09 17:16 ` [PATCH net-next 5/6] bnx2: Handle DMA mapping errors Michael Chan @ 2008-10-09 17:16 ` Michael Chan 2008-10-09 19:27 ` David Miller 2008-10-09 19:21 ` [PATCH net-next 1/6] bnx2: Add bnx2_shutdown_chip() David Miller [not found] ` <1223572568-1298-3-git-send-email-mchan@broadcom.com> 5 siblings, 1 reply; 14+ messages in thread From: Michael Chan @ 2008-10-09 17:16 UTC (permalink / raw) To: davem; +Cc: netdev, Michael Chan Signed-off-by: Michael Chan <mchan@broadcom.com> --- drivers/net/bnx2.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index a95ca4f..430d430 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c @@ -57,8 +57,8 @@ #define DRV_MODULE_NAME "bnx2" #define PFX DRV_MODULE_NAME ": " -#define DRV_MODULE_VERSION "1.8.0" -#define DRV_MODULE_RELDATE "Aug 14, 2008" +#define DRV_MODULE_VERSION "1.8.1" +#define DRV_MODULE_RELDATE "Oct 7, 2008" #define RUN_AT(x) (jiffies + (x)) -- 1.5.6.GIT ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH net-next 6/6] bnx2: Update version to 1.8.1. 2008-10-09 17:16 ` [PATCH net-next 6/6] bnx2: Update version to 1.8.1 Michael Chan @ 2008-10-09 19:27 ` David Miller 0 siblings, 0 replies; 14+ messages in thread From: David Miller @ 2008-10-09 19:27 UTC (permalink / raw) To: mchan; +Cc: netdev From: "Michael Chan" <mchan@broadcom.com> Date: Thu, 9 Oct 2008 10:16:08 -0700 > Signed-off-by: Michael Chan <mchan@broadcom.com> Also applied, thanks a lot. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH net-next 1/6] bnx2: Add bnx2_shutdown_chip(). 2008-10-09 17:16 [PATCH net-next 1/6] bnx2: Add bnx2_shutdown_chip() Michael Chan ` (3 preceding siblings ...) 2008-10-09 17:16 ` [PATCH net-next 6/6] bnx2: Update version to 1.8.1 Michael Chan @ 2008-10-09 19:21 ` David Miller [not found] ` <1223572568-1298-3-git-send-email-mchan@broadcom.com> 5 siblings, 0 replies; 14+ messages in thread From: David Miller @ 2008-10-09 19:21 UTC (permalink / raw) To: mchan; +Cc: netdev, benli, mcarlson From: "Michael Chan" <mchan@broadcom.com> Date: Thu, 9 Oct 2008 10:16:03 -0700 > This logic is used in bnx2_close() and bnx2_suspend() and > so should be separated out into a separate function. > > Signed-off-by: Michael Chan <mchan@broadcom.com> > Signed-off-by: Benjamin Li <benli@broadcom.com> > Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Applied. ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <1223572568-1298-3-git-send-email-mchan@broadcom.com>]
* Re: [PATCH net-next 3/6] bnx2: Update 5706/5708 firmware. [not found] ` <1223572568-1298-3-git-send-email-mchan@broadcom.com> @ 2008-10-09 19:23 ` David Miller 0 siblings, 0 replies; 14+ messages in thread From: David Miller @ 2008-10-09 19:23 UTC (permalink / raw) To: mchan; +Cc: netdev From: "Michael Chan" <mchan@broadcom.com> Date: Thu, 9 Oct 2008 10:16:05 -0700 > With this new firmware, the driver no longer has to modify the > TCP/IP header fields when transmitting TSO packets. > > Signed-off-by: Michael Chan <mchan@broadcom.com> Applied. ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2008-10-09 21:26 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-09 17:16 [PATCH net-next 1/6] bnx2: Add bnx2_shutdown_chip() Michael Chan
2008-10-09 17:16 ` [PATCH net-next 2/6] bnx2: Check netif_running() in all ethtool operations Michael Chan
2008-10-09 19:22 ` David Miller
2008-10-09 20:59 ` Michael Chan
2008-10-09 21:26 ` David Miller
2008-10-09 17:16 ` [PATCH net-next 4/6] bnx2: Eliminate TSO header modifications Michael Chan
2008-10-09 19:25 ` David Miller
2008-10-09 20:56 ` Michael Chan
2008-10-09 17:16 ` [PATCH net-next 5/6] bnx2: Handle DMA mapping errors Michael Chan
2008-10-09 19:26 ` David Miller
2008-10-09 17:16 ` [PATCH net-next 6/6] bnx2: Update version to 1.8.1 Michael Chan
2008-10-09 19:27 ` David Miller
2008-10-09 19:21 ` [PATCH net-next 1/6] bnx2: Add bnx2_shutdown_chip() David Miller
[not found] ` <1223572568-1298-3-git-send-email-mchan@broadcom.com>
2008-10-09 19:23 ` [PATCH net-next 3/6] bnx2: Update 5706/5708 firmware 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).